1, quote AspNetPager.dll.
2. Place the Repeater data-bound control.
<ID= "Repeater1" runat= "Server"> < ItemTemplate> //binding the displayed list code </ ItemTemplate> </asp:repeater>
3. The following code appears when you add a Aspnetpager paging control to a page.
<%@ Register Assembly="Aspnetpager"Namespace="Wuqi.webdiyer"TagPrefix="Webdiyer" %>
<Webdiyer:aspnetpagerID= "AspNetPager1"CssClass= "Paginator"PageSize= "Ten"Alwaysshow= "true"Firstpagetext= "Home"Prevpagetext= "Previous page"NextPageText= "Next Page"CurrentPageIndex= "1"Lastpagetext= "Last"runat= "Server"onpagechanged= "Aspnetpager1_pagechanged"> </Webdiyer:aspnetpager>
// Double-click a paging control protected void Aspnetpager1_pagechanged (object sender, EventArgs e) { binddata (); }
4.. cs file write bound data method.
Public voidBinddata () {//here is the data source of the query, change this to have data. DataSet ds =NewDataSet (); //set up a paging data sourcePagedDataSource Pagesource =NewPagedDataSource (); Pagesource.allowpaging=true;//set whether to page outPagesource.pagesize = pagercontrol.pagesize;//Number of pagesPagesource.currentpageindex = Pagercontrol.currentpageindex-1;//This is the current page, do not decrement 1,pageddatasource is starting from 0. Pagesource.datasource = ds. table[0]. DefaultView; Pagercontrol.recordcount=Pagesource.datasourcecount; Repeater1.datasource=Pagersource; Repeater1.databind (); }
5. Results
PagedDataSource data-bound controls and Aspnetpager pagination controls in combination with a list of pages