当前位置:编程学习 > C#/ASP.NET >>

绑定datatable的listview如何实现分页,不用数据源

listview中的LayoutTemplate如下
<LayoutTemplate>
                <table>
                    <tr>
                        <td>
                            <table ID="itemPlaceholderContainer" runat="server" border="1">
                                <tr>
                                    <th>序号</th>
                                    <th>姓名</th>
                                    <th>工号</th>
                                    <th>性别</th>
                                    <th>所在部门</th>
                                    <th>职称</th>
                                    <th>职位</th>
                                    <th>操作</th>
                                </tr>
                                <tr ID="itemPlaceholder" runat="server">
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr runat="server">
                        <td runat="server" class="classPager">
                            <asp:DataPager ID="DataPager1" runat="server" PageSize="12">
                                <Fields>
                                    <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" 
                                        ShowNextPageButton="False" ShowPreviousPageButton="False" />
                                    <asp:NumericPagerField />
                                    <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" 
                                        ShowNextPageButton="False" ShowPreviousPageButton="False" />
                                </Fields>
                            </asp:DataPager>
                        </td>
                    </tr>
                </table>
            </LayoutTemplate>
在后台,我用datatable存储获得的数据,再绑定到listview
ListView1.DataSource = dt1;
            ListView1.DataBind();
请问我怎么实现分页的功能?后台要写哪些方法? --------------------编程问答-------------------- 你可以使用第三方的分页控件 比如 aspnetpager
后台绑定数据的方法需要你去获取分页数据,向分页方法或分页存储过程传入页码,起始结束页 每页显示数等参数。
然后获取到得数据绑定到你的ListView1 即可
详见此处
http://www.webdiyer.com/AspNetPagerDemo/PagedDataList/default.aspx --------------------编程问答-------------------- 解决了:http://blog.sina.com.cn/s/blog_4adbf03101009p0x.html
补充:.NET技术 ,  ASP.NET
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,