ASP.NET分页_.NET_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > .NET > ASP.NET分页

ASP.NET分页

 2014/11/12 15:15:45  金融交易软件开发  程序员俱乐部  我要评论(0)
  • 摘要:[代码][C#]代码12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879///<summary>///分页内容///</summary>///<paramname="size">页面大小</param>
  • 标签:.net ASP.NET net

 [代码][C#]代码 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 class="c# color1">/// <summary> /// 分页内容 /// </summary> /// <param name="size">页面大小</param> /// <param name="count">页面数量</param> /// <param name="currendIndex">当前页</param> /// <param name="pattern">url模式:demo.aspx?page={0}</param> /// <param name="target">窗口模式</param> /// <returns></returns> public static string get_pagenation(int size,                                     int count,                                     int currendIndex,                                     string pattern,                                     string target) {     //1>打开窗口目标     target = string.IsNullOrEmpty(target) ? "_top" : target;     //2>总页数     int pageCount = count / size;     pageCount = pageCount * size == count ? pageCount : pageCount + 1;     //3>分页内容     StringBuilder strHtml = new StringBuilder();     strHtml.Append("<span class='pagenation'>");       #region 首部处理     if (currendIndex > 1)     {         strHtml.AppendFormat("<a href='1' target='{0}'>[首页]</a>", target);         strHtml.AppendFormat("<a href='{0}' target='{1}'>[上一页]</a>", string.Format(pattern, currendIndex - 1), target);     }     else     {         strHtml.Append("<span class='disabled'>[首页]</span>&nbsp;&nbsp;<span class='disabled'>[上一页]</span>");     }     #endregion       #region 中间部分     int i = 1;       int right = (currendIndex + 4) > pageCount ? pageCount : currendIndex + 4;     if (currendIndex > 6)     {         i = currendIndex - 5;     }     else     {         right = pageCount >= 10 ? 10 : pageCount;     }     for (; i <= right; i++)     {         if (i == currendIndex)         {             strHtml.AppendFormat("<font class='current'>{0}</font>", i);             strHtml.AppendLine();             continue;         }         strHtml.AppendFormat("<a href='{0}' target='{1}'>[{2}]</a>", string.Format(pattern, i), target, i);         strHtml.AppendLine();     }     #endregion       #region 尾部处理     if (currendIndex == pageCount)     {         strHtml.Append("<span class='disabled'>[下一页]</span><span class='disabled'>[末页]</span>");         strHtml.AppendFormat("总共({0})页", pageCount);     }     else     {         strHtml.AppendFormat("<a href='{0}' target='{1}'>[下一页]</a>", string.Format(pattern, currendIndex + 1), target);         strHtml.AppendFormat("<a href='{0}' target='{1}'>[末页]</a>", string.Format(pattern, pageCount), target);         strHtml.AppendFormat("&nbsp;&nbsp;<label>总共({0})页</label>", pageCount);     }     #endregion       strHtml.Append("</span>");       return strHtml.ToString(); }
上一篇: 豪情-关于生活工作学习之感悟-第二篇 下一篇: 没有下一篇了!
发表评论
用户名: 匿名