具有无限页码的ASP.Net GridView数字分页

时间:2011-05-19 07:42:55

标签: asp.net pagination

我有一个启用了分页的GridView,并且PageSettings Mode设置为“Numeric”。此设置当前正确显示十页或更少:

1 2 3 4 5 6 7 8 9 10

当它到达11个或更多页面时,它会在末尾附加“...”(省略号)以便对页面进行分页。十一页或更多页面如下:

1 2 3 4 5 6 7 8 9 10 ...

如何将其配置为不同数量的页面?我希望他们在显示“......”之前上升到25。类似的东西:

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 ...

修改

答案在评论中。使用PagerSettings-PageButtonCount属性,如下所示:

<asp:GridView ID="gvData" runat="server" AllowPaging=true PageSize=5 PagerSettings-PageButtonCount=20></asp:GridView>

1 个答案:

答案 0 :(得分:4)

使用Gridview的PagerSettings-PageButtonCount属性。

例如

<asp:GridView ID="[gridname]" runat="server" AllowPaging=true PageSize=[page size] PagerSettings-PageButtonCount=[number of page buttons]></asp:GridView>