AspNetPager使用方法:(自己的一些總結(jié),肯定會(huì)有不足的地方,望不吝指教?。?/font>
1、首先引用AspNetPager.dll;
2、在所使用的前臺(tái)頁面加入:<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>,
指明DLL地址和命名空間;
3、在頁面使用aspnetPager控件:(根據(jù)情況,自定義下面的屬性)
<webdiyer:AspNetPager ID="AspNetPager1" class="quotes" runat="server" CustomInfoHTML="<span class="pageDesc">共有 %RecordCount% 頁 %CurrentPageIndex% / %PageCount% 頁</span>"
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>
標(biāo)紅的是點(diǎn)擊觸發(fā)事件:
在.cs后臺(tái)頁面加上此方法:
protected void AspNetPager1_PageChanging(object src, Wuqi.Webdiyer.PageChangingEventArgs e)
{
AspNetPager1.CurrentPageIndex = e.NewPageIndex;//指定顯示的頁數(shù)
}
4、同時(shí),還要指定以下值:
AspNetPager1.PageSize=10;//每頁顯示多少條記錄
AspNetPager1.RecordCount=100;//總頁數(shù)
5、因?yàn)樵摽丶c數(shù)據(jù)顯示和綁定是獨(dú)立的,所以可以根據(jù)所要顯示的頁數(shù)AspNetPager1.CurrentPageIndex,取得該頁數(shù)據(jù)datatable,然后再使用repeater等控件綁定:
Repeater1.DataSource = dt;
Repeater1.DataBind();
聯(lián)系客服