日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

分页实现

發(fā)布時間:2025/3/15 编程问答 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 分页实现 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
public interface IGetList<T>{/// <summary>/// 返回一個集合/// </summary>/// <param name="pageindex">當(dāng)前頁</param>/// <param name="pagenumber">每頁顯示多少條</param>/// <param name="totle">總共多少條</param>/// <param name="dic">查詢條件以字典放入</param>/// <returns></returns>List<T> GetList(int pageindex,int pagenumber,out int totle,Dictionary<string,string> dic);} View Code protected int totle = 0;protected int pageindex = 1;protected int pagenumber = 20;protected double pagecount = 1;protected System.Text.StringBuilder sbpager = new System.Text.StringBuilder();protected List<People> lis = new List<People>();protected void Page_Load(object sender, EventArgs e){InintPager();}/// <summary>/// 初始化分頁條碼/// </summary>protected void InintPager(){#region 查詢條件Dictionary<string, string> dic = new Dictionary<string, string>(); #endregionstring linkstr = "index.aspx?&pageindex=";#region 產(chǎn)生分頁條碼int totle = 0;int pageindex = 1;if (!int.TryParse(Request["pageindex"], out pageindex)){pageindex = 1;}int pagenumber = 20;IGetList<People> bll = new Pagerok.BLL();lis = bll.GetList(pageindex, pagenumber, out totle,dic);pagecount = Math.Ceiling(totle * 1.0 / pagenumber);sbpager.Append(" <a href='#'>共" + pagecount + "頁</a>");#region MyRegionsbpager.Append("<a href='"+linkstr + 1 + "'>首頁</a> ");if (pageindex != 1){sbpager.Append("<a href='"+linkstr + (pageindex - 1) + "'>上一頁</a> ");}#endregionif (pagecount <= 10){#region MyRegionfor (int i = 0; i < pagecount; i++){if ((i + 1) == pageindex){sbpager.Append("<a class='current' href='#'>" + (i + 1) + " </a>");}else{sbpager.Append("<a href='"+linkstr + (i + 1) + "'>" + (i + 1) + " </a>");}}#endregion}else if (pageindex < 5){#region MyRegionfor (int i = 0; i < 10; i++){if ((i + 1) == pageindex){sbpager.Append("<a class='current' href='#'>" + (i + 1) + " </a>");}else{sbpager.Append("<a href='" + linkstr + (i + 1) + "'>" + (i + 1) + " </a>");}}#endregion}else if (pageindex > pagecount - 5){#region MyRegionint t = int.Parse(pagecount.ToString()) - 10;for (int i = t; i < pagecount; i++){if ((i + 1) == pageindex){sbpager.Append("<a class='current' href='#'>" + (i + 1) + " </a>");}else{sbpager.Append("<a href='" + linkstr + (i + 1) + "'>" + (i + 1) + " </a>");}} #endregion}else{#region MyRegionint t1 = pageindex - 5;int t2 = pageindex + 4;for (int i = t1; i < t2; i++){if ((i + 1) == pageindex){sbpager.Append("<a class='current' href='#'>" + (i + 1) + " </a>");}else{sbpager.Append("<a href='" + linkstr + (i + 1) + "'>" + (i + 1) + " </a>");}} #endregion}#region MyRegionif (pageindex != pagecount){sbpager.Append("<a href='" + linkstr + (pageindex + 1) + "'>下一頁</a> ");} #endregionsbpager.Append("<a href=" + linkstr + pagecount + ">尾頁</a>");#endregion} View Code

?

轉(zhuǎn)載于:https://www.cnblogs.com/fierceeagle/p/5419246.html

總結(jié)

以上是生活随笔為你收集整理的分页实现的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。