_Bluesky‘s Blog

滚滚长江东逝水,浪花淘尽英雄。是非成败转头空。青山依旧在,几度夕阳红。白发渔樵江渚上,惯看秋月春风。一壶浊酒喜相逢。古今多少事,都付笑谈中。
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

AspNetPager使用方法之一

Posted on 2012-04-01 16:03  _Bluesky  阅读(418)  评论(0)    收藏  举报

AspNetPager使用方法:(自己的一些总结,肯定会有不足的地方,望不吝指教!)

AspNetPager.dll下载的地址 

1、首先引用AspNetPager.dll;

2、在所使用的前台页面加入:<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>,

    指明DLL地址和命名空间;

3、在页面使用aspnetPager控件:(根据情况,自定义下面的属性)

<webdiyer:AspNetPager ID="AspNetPager1" class="quotes" runat="server" CustomInfoHTML="&lt;span class=&quot;pageDesc&quot;&gt;共有 %RecordCount% 页 %CurrentPageIndex% / %PageCount% 页&lt;/span&gt;"
                        FirstPageText="首页" LastPageText="尾页" NextPageText="下一页" PrevPageText="上一页" Width="95%"
                        CustomInfoStyle="" PagingButtonsClass="PageButton" AlwaysShowFirstLastPageNumber="True"
                        CurrentPageButtonClass="PageButtonCurrent" PagingButtonSpacing="2px" PagingButtonsStyle=""
                        ShowPageIndexBox="Never" CurrentPageButtonStyle="" LayoutType="Table" OnPageChanging="AspNetPager1_PageChanging"
                        ShowCustomInfoSection="Left">
                    </webdiyer:AspNetPager>

 标红的是点击触发事件:

       在.cs后台页面加上此方法:

        protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
        {
            AspNetPager1.CurrentPageIndex = e.NewPageIndex;//指定显示的页数
        }

4、同时,还要指定以下值: 

      AspNetPager1.PageSize=10;//每页显示多少条记录

      AspNetPager1.RecordCount=100;//总页数

5、因为该控件与数据显示和绑定是独立的,所以可以根据所要显示的页数AspNetPager1.CurrentPageIndex,取得该页数据datatable,然后再使用repeater等控件绑定:

      Repeater1.DataSource = dt;
      Repeater1.DataBind();