ASP.NET 中 ListView 的自定义 DataPager
我想获得 C# 和 VB.NET 建议。
我有以下 DataPager 来处理 ListView 的分页。
DataPager 标记
<asp:DataPager ID="dpComputer" runat="server"
PagedControlID="lvComputer" PageSize="10">
<Fields>
<asp:NextPreviousPagerField ShowFirstPageButton="True" ShowNextPageButton="False" />
<asp:NumericPagerField NumericButtonCssClass="dpTimeSheet" ButtonCount="100" ButtonType="Image" />
<asp:NextPreviousPagerField ShowLastPageButton="True" ShowPreviousPageButton="False" />
</Fields>
</asp:DataPager>
处理 DataPager 事件
Protected Sub lvComputer_PagePropertiesChanged(ByVal sender As Object, ByVal e As EventArgs) Handles lvComputer.PagePropertiesChanged
LoadData()
End Sub
显示/隐藏 datapager
Protected Sub lvComputer_DataBound(ByVal sender As Object, ByVal e As EventArgs) Handles lvComputer.DataBound
dpComputer.Visible = dpComputer.PageSize <= dpComputer.TotalRowCount
End Sub
上面的代码产生以下输出:
第一页 上一页 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 依此类推 下一页 最后一页
我上面的代码工作正常。然而,当ListView lvComputer的TotalRows超过200时,页面上的分页数很多。 我想按以下格式显示寻呼号码:
第一页 上一页 1 2 3 ..... 9 10 11 下一页 最后一页
首页 上一页 5 6 7 8 ..... 13 14 15 16 下一页 末页
我需要以编程方式修改数据分页器以获得如上所述的所需结果例子?谢谢。
I'd like to get both C# and VB.NET suggestion.
I have the follow DataPager to handle the paging of ListView.
DataPager mark-up
<asp:DataPager ID="dpComputer" runat="server"
PagedControlID="lvComputer" PageSize="10">
<Fields>
<asp:NextPreviousPagerField ShowFirstPageButton="True" ShowNextPageButton="False" />
<asp:NumericPagerField NumericButtonCssClass="dpTimeSheet" ButtonCount="100" ButtonType="Image" />
<asp:NextPreviousPagerField ShowLastPageButton="True" ShowPreviousPageButton="False" />
</Fields>
</asp:DataPager>
handling DataPager event
Protected Sub lvComputer_PagePropertiesChanged(ByVal sender As Object, ByVal e As EventArgs) Handles lvComputer.PagePropertiesChanged
LoadData()
End Sub
show/hide datapager
Protected Sub lvComputer_DataBound(ByVal sender As Object, ByVal e As EventArgs) Handles lvComputer.DataBound
dpComputer.Visible = dpComputer.PageSize <= dpComputer.TotalRowCount
End Sub
The code above makes the following output:
First Previous 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 and so on Next Last
The code I have above works fine. However,when TotalRows of ListView lvComputer is more than 200, there are a lot of paging number on the page.
I want to show paging number like something in the following format:
First Previous 1 2 3 ..... 9 10 11 Next Last
First Previous 5 6 7 8 ..... 13 14 15 16 Next Last
What do I need to do programmatically to modify the datapager to get the desired result like above example? Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论