ASP.NET分页控件示例

AspNetPager控件使用方式:引用到项目>工具箱右键>选择项>浏览引用的DLL文件

此时工具箱多了一个控件,直接拖到页面上,自动生成一下代码.

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

这里的上一页和下一页都可以在图形界面下设置,非常简单使用

<webdiyer:AspNetPager ID="AspNetPager1" runat="server"
            CustomInfoHTML="共%PageCount%页,当前为第%CurrentPageIndex%页,每页%PageSize%条"
            FirstPageText="首页" LastPageText="尾页" NextPageText="下一页"
            PageIndexBoxType="TextBox" PrevPageText="上一页" ShowBoxThreshold="5"
            ShowCustomInfoSection="Left" ShowPageIndexBox="Auto" SubmitButtonText="Go"
            TextAfterPageIndexBox="页" TextBeforePageIndexBox="转到" UrlPaging="True">
        </webdiyer:AspNetPager>

后台代码:

NorthwindEntities db = new NorthwindEntities();
        List<Customers> tmpList= db.Customers.ToList();
        AspNetPager1.PageSize = 10;     

        AspNetPager1.RecordCount=tmpList.Count;            //设置分页控件的总记录数
        //这就是跳过的数据条数
        int skipCount;
        if (Request["page"] != null)
            skipCount = (AspNetPager1.CurrentPageIndex - 1) * AspNetPager1.PageSize;            //这里实现了gridview和分页控件之间的关联
        else
            skipCount = 0;
        this.GridView1.DataSource = tmpList.Skip(skipCount).Take(AspNetPager1.PageSize);
        this.GridView1.DataBind();

 示例源码可以在 http://download.csdn.net/source/3546273 处下载

运行效果

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值