国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

asp.net分頁的制作

2019-11-14 13:39:48
字體:
來源:轉載
供稿:網友

/// <summary>
/// 數據分頁方法
/// </summary>
/// <param name="PageIndex">當前頁</param>
/// <param name="PageSize">每頁顯示數量</param>
/// <param name="PageCount">總數據</param>
/// <param name="Url">鏈接,如:list.aspx?id=1234</param>
/// <returns></returns>
public static string GetPage(int PageIndex, int PageSize, int RecordCount, string Url)
{
StringBuilder sb = new StringBuilder();
try
{
//計算總頁數
int PageCount = RecordCount % PageSize == 0 ? RecordCount / PageSize : RecordCount / PageSize + 1;
if (PageIndex < 1)
{
PageIndex = 1;
}
if (PageIndex > PageCount)
{
PageIndex = PageCount;
}
string StarPage = "";//首頁
string EndPage = "";//尾頁
string PRePage = "";//上一頁
string NextPage = "";//下一頁
//首頁和上一頁的鏈接
if (PageIndex <= 1 || PageCount <= 1)
{
StarPage = "";
PrePage = "";
}
else
{
StarPage = "";
PrePage = "<li class=/"previous/"><a href=/"" + Url + "&page=" + (PageIndex - 1) + "/">上一頁</a></li>";
}
//末頁和下一頁的鏈接
if (PageIndex == PageCount || PageCount <= 1)
{
EndPage = "";
NextPage = "";
}
else
{
EndPage = "";
NextPage = "<li class=/"next/"><a href=/"" + Url + "&page=" + (PageIndex + 1) + "/">下一頁</a></li>";
}
//頁碼輸出
int PagerStart = 1;//第一個頁碼
if (PageCount >= 5)
{
PagerStart = PageIndex % 5 == 0 ? PageIndex - 2 : PageIndex - PageIndex % 5;
}
if (PagerStart < 1)
{
PagerStart = 1;
}
string NumBtn = "";
for (int i = PagerStart; i < PagerStart + 5 && i <= PageCount; i++)
{
if (i == PageIndex)
{
NumBtn += "<li class=/"current/"><a>" + i + "</a>";
}
else
{
NumBtn += "<li><a href=/"" + Url + "&page=" + i + "/">" + i + "</a></li>";
}
}
sb.Append(StarPage + PrePage + NumBtn + NextPage + EndPage);
}
catch
{
sb.Append("");
}
return sb.ToString();
}


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 大港区| 晋城| 峡江县| 斗六市| 德州市| 保靖县| 右玉县| 礼泉县| 炎陵县| 壶关县| 鹰潭市| 抚宁县| 通城县| 务川| 云和县| 桂阳县| 宜兴市| 隆安县| 铜鼓县| 阿拉善右旗| 峨眉山市| 乌兰察布市| 新蔡县| 金乡县| 蕉岭县| 锦州市| 东阳市| 锡林郭勒盟| 内黄县| 图们市| 昌平区| 连州市| 水富县| 汾西县| 钦州市| 涪陵区| 寿光市| 焉耆| 庆城县| 青川县| 闵行区|