//分頁代碼 #region 分頁樣式 1 2 3 4 5 6 7 8 .../// <summary>/// 分頁樣式 1 2 3 4 5 6 7 8 .../// </summary>ExtPage 顯示的分頁條數(shù)/// <param name="Count"></param>/// <returns></returns> public static string GetPager(int CountNumber, int pageSize, int CurrentPage, string pageCss, int ExtPage){StringBuilder html = new StringBuilder();if (string.IsNullOrEmpty(pageCss))html.Append("<div>");elsehtml.Append("<div class=\"" + pageCss + "\">");html.Append("<a href='?page=1'>首頁</a>");//計(jì)算總頁數(shù) int PageCount = 0;if (CountNumber % pageSize == 0)PageCount = CountNumber / pageSize;elsePageCount = (CountNumber / pageSize) + 1;//計(jì)算開始頁-結(jié)束頁 int StartPage = 0, EndPage = 10;if (CurrentPage <= PageCount){if (CurrentPage / ExtPage >= 1){int extPage = CurrentPage / ExtPage;StartPage = extPage * ExtPage - 1;EndPage = StartPage + ExtPage + 1;}else{EndPage = StartPage + ExtPage;}}if (EndPage > PageCount)EndPage = PageCount;if (StartPage < 1)StartPage = 1;if (CurrentPage > 1)html.Append(" <a href='?page=" + (CurrentPage - 1) + "'>上頁</a>");elsehtml.Append(" <a href='javascript:void(0)'>上頁</a> ");for (int i = StartPage; i <= EndPage; i++){if (i == CurrentPage)html.Append("<span>" + i + "</span>");elsehtml.Append("<a href='?page=" + i + "'>" + i + "</a>");}if (CurrentPage < PageCount)html.Append("<a href='?page=" + (CurrentPage + 1) + "'>下頁</a>");elsehtml.Append("<a href='javascript:void(0)'>下頁</a>");html.Append("<a href='?page=" + PageCount + "'>末頁</a>");html.Append("<a>第" + CurrentPage + "/" + PageCount + "頁</a>");html.Append("</div>");return html.ToString();}#endregion
聯(lián)系客服