實例懶得做
下面是一個helper類
Code
namespace System
{
public enum BarStyle
{
yahoo
}
public static class PagerBarExtension
{
public static string RenderPagerBar(this HtmlHelper html
{
return RenderPagerBar(html
}
public static string RenderPagerBar(this HtmlHelper html
{
return RenderPagerBar(html
}
public static string RenderPagerBar(this HtmlHelper html
{
if (total ==
{
return
}
else
{
StringBuilder sb = new StringBuilder();
string _path = html
sb
sb
sb
string queryString = html
if (queryString
{
queryString +=
}
Regex re = new Regex(@
string result = re
if (page !=
{
sb
sb
}
if(page>(show+
{
sb
}
for (int i = page
{
if (i == page)
{
sb
}
else
{
if (i >
{
sb
}
}
}
if (page < (total
{
sb
}
if (page < total)
{
sb
sb
}
sb
sb
return sb
}
}
}
}
使用(VIEW)
Code
<%@ Page Language=
<asp:Content ID=
<title>Home Page</title>
<link rel=
</asp:Content>
<asp:Content ID=
<%= Html
<%= Html
<%= Html
數
<%= Html
<%= Html
<%= Html
<%= Html
<%= Html
<%= Html
<%= Html
</asp:Content>
最後一個int參數表示顯示當前頁左右各多少個頁碼
效果
public ActionResult Index(int? page
{
int _page = page??
ViewData[
ViewData[
ViewData[
return View();
}
不是啥高深的東西
計算總頁數和skip啥的就自己搞啦
From:http://tw.wingwit.com/Article/program/net/201311/12180.html