一个很好用的分页控件

一个很好用的分页控件,本来想将用户控件的时候说的,但是既然涉及到了,就简单的说下用法

控件大家可以找我要,小白和小贝也都有,也可以从这个地址下载:

http://download.csdn.net/detail/gongchuanbo/1258255

1.首先将dll文件添加引用

2.在aspx页面添加注册:

<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>

在需要的位置添加如下代码:

<webdiyer:AspNetPager ID="AspNetPager1" runat="server" OnPageChanged="AspNetPager1_PageChanged"
                                                                    
        ShowCustomInfoSection="left" ShowInputBox="Auto" AlwaysShow="True" CustomInfoHTML="<font color='#333333'>共 %RecordCount% 行/每页%PageSize%行 第%CurrentPageIndex%/%PageCount%页 顺序 %StartRecordIndex%-%EndRecordIndex%</font> "
                                                                    
        NumericButtonCount="10" FirstPageText="首页" LastPageText="末页" NextPageText="下页"
                                                                    
        PrevPageText="上页" CustomInfoSectionWidth="65%" CssClass="page_text" ShowBoxThreshold="2"
                                                                    
        InputBoxClass="pagetext" SubmitButtonClass="BtnStyle" SubmitButtonText="Go" 
        NavigationButtonType="Image">
                                                                </webdiyer:AspNetPager>


在控件的AspNetPager1_PageChanged事件中添加如下代码:

DataBindGride();

DataBindGride函数的代码如下:

 	    Users u = new Users();
            this.AspNetPager1.RecordCount = Int32.Parse(u.GetArticlCount().ToString());

            int pageIndex = (this.AspNetPager1.CurrentPageIndex);

            int pageSize = this.AspNetPager1.PageSize = 10;

            this.GridView1.DataSource = u.GetArticleInfo(pageIndex, pageSize);

            GridView1.DataBind();

其中u.GetArticlCount()方法获取表中总的记录行数,u.GetArticleInfo方法根据当前的页码和每页显示的记录数获取记录


在page_load中添加如下代码:

if (!IsPostBack)
            {
                DataBindGride();
            }



 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

巴山却话

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值