首页 > 代码库 > AspNetPager控件分页使用方法
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();}
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。