码迷,mamicode.com
首页 > Web开发 > 详细

AspNetPager分页控件的使用方法

时间:2017-06-28 10:55:33      阅读:243      评论:0      收藏:0      [点我收藏+]

标签:asp   分页控件   desc   style   create   change   拖拽   tom   xbox   

1、 首先将AspNetPager.dll复制于应用程序下的bin目录,打开解决方案,引入dll文件 (通过NuGet获取)

2、 在工具栏中添加控件,这样可以支持拖拽使用 

3、页面拖入分页控件,设置基本样式(建议跟repeater控件绑定)

<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
技术分享
<webdiyer:AspNetPager ID="anp" runat="server" AlwaysShow="true" CssClass="anpager" CurrentPageButtonClass="cpb" CustomInfoHTML="共%RecordCount%条,第%CurrentPageIndex%页 /共%PageCount% 页" FirstPageText="首页" LastPageText="尾页" NextPageText="下一页" OnPageChanged="anpList_PageChanged" PageIndexBoxType="DropDownList" PageSize="1" PagingButtonSpacing="" PrevPageText="上一页" ShowCustomInfoSection="Left" ShowMoreButtons="False" ShowPageIndexBox="Always" SubmitButtonText="Go" TextAfterPageIndexBox="页" TextBeforePageIndexBox="转到"></webdiyer:AspNetPager>
View Code

4、编写后台代码change事件

     protected void anpList_PageChanged(object sender, EventArgs e)
        {
            BindRep();
        }

        private void BindRep()
        {
            int pagesize = anp.PageSize;
            int pageindex = anp.CurrentPageIndex;
            rep.DataSource = dal.gb_data.OrderByDescending(a => a.createdate).Skip((pageindex - 1) * pagesize).Take(pagesize).ToList();
            rep.DataBind();
        }

5、IsPostBack中加入

          anp.RecordCount = dal.gb_data.Count();
                BindRep();

 

AspNetPager分页控件的使用方法

标签:asp   分页控件   desc   style   create   change   拖拽   tom   xbox   

原文地址:http://www.cnblogs.com/wyt007/p/7088500.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!