1. Reference aspNetPager.dll.
2. Place the Repeater data binding control.
<asp:Repeater ID="Repeater1" runat="server"> <ItemTemplate> //Bind the displayed list code</ItemTemplate> </asp:Repeater>
3. Add the AspNetPager pagination control to the page, the following code will appear.
<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPRefix="webdiyer" %>
<webdiyer:AspNetPager ID="AspNetPager1" CSSClass="paginator" PageSize="10" AlwaysShow="true" FirstPageText="Home" PrevPageText="Previous page" NextPageText="Next page" CurrentPageIndex="1" LastPageText="Last page" runat="server" OnPageChanged="AspNetPager1_PageChanged"> </webdiyer:AspNetPager>
//Double-click the pagination control protected void AspNetPager1_PageChanged(object sender, EventArgs e) { BindData(); }4. Method for writing bound data in .cs file.
public void BindData() { //Here is the query data source, change this to one with data. DataSet ds = new DataSet(); //Set the paged data source PagedDataSource pageSource = new PagedDataSource(); pageSource.AllowPaging = true;//Set whether to paging pageSource.PageSize = pagerControl.PageSize;//The number of pages pageSource.CurrentPageIndex = pagerControl.CurrentPageIndex - 1;//This is the current page, do not reduce 1, PagedDataSource starts from 0. pageSource.DataSource = ds.Table[0].DefaultView; pagerControl.RecordCount = pageSource.DataSourceCount; Repeater1.DataSource = pagerSource; Repeater1.DataBind(); } 5. Results