AspNetPager控件分页使用方法
AspNetPager控件官方下载地址:http://www.webdiyer.com/aspnetpager/
把控件加到项目中(添加自定义控件的方法),并把它拖放到页面上
<asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <table> <asp:Repeater ID="Repeater1" runat="server"> <ItemTemplate> <tr> <td><%#Eval("ID") %></td> <td><%#Eval("TaskTime") %></td> <td><%#Eval("UName") %></td> </tr> </ItemTemplate> </asp:Repeater> </table> <webdiyer:AspNetPager ID="AspNetPager1" runat="server" AlwaysShow="true" FirstPageText="首页" LastPageText="尾页" PrevPageText="上一页" NextPageText="下一页" ShowPageIndexBox="Always" PageIndexBoxType="DropDownList" TextBeforePageIndexBox="跳转到" OnPageChanged="AspNetPager1_PageChanged"></webdiyer:AspNetPager> </ContentTemplate> </asp:UpdatePanel>
Page_Load事件
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { int recordCount = new VTaskBLL().GetTaskCount("1=1"); AspNetPager1.RecordCount = recordCount; BindReapter(); } }
BindReapter方法
private void BindReapter() { int currentPage = AspNetPager1.CurrentPageIndex; int pageSize = AspNetPager1.PageSize = 10; List<VTaskModel> vtaskList = new VTaskBLL().GetTaskPage(pageSize, currentPage); Repeater1.DataSource = vtaskList; Repeater1.DataBind(); }
翻页事件
protected void AspNetPager1_PageChanged(object sender, EventArgs e) { BindReapter(); }
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。