public void GenerateControls(int count) { pageId = RequestUtils.GetPageId(this); if (pageId <= 0) { pageId = 1; } const int pagerCount = 10; if (pageSize <= 0 || pageId < 1) { return; } int pageCount = (count - 1 + pageSize) / pageSize; int startPage = ((pageId - 1) / pagerCount) * pagerCount; int endPage = startPage + pagerCount; string url = base.Request.Url.OriginalString; if (url.Contains("?")) { int index = url.IndexOf("pg="); if (index > 0) { url = url.Substring(0, index); } else { url += "&"; } } else { url += "?"; } var sb = new StringBuilder(); if (startPage >= pagerCount) { sb.AppendFormat("<a href='{0}pg={1}'>...</a> ", url, startPage - pagerCount); } for (int i = startPage + 1; i <= endPage && i <= pageCount; i++) { string styleStr = i == pageId ? " style='text-decoration:underline'" : ""; sb.AppendFormat("<a href='{0}pg={1}'{2}>{1}</a> ", url, i, styleStr); } if (endPage < pageCount) { sb.AppendFormat("<a href='{0}pg={1}'>...</a> ", url, endPage + 1); } lblContent.Text = sb.ToString(); }
void LoadData() { int id = RequestUtils.GetPageId(this); if (id != 0) { using (GmConnection conn = Global.CreateConnection()) { page = LinkExchangePage.GetLinkExchangePage(conn, id); } } if (page == null) { WebUtils.Redirect(this, "Admin/LinkExchangePages.aspx"); } }