1. Add DLL reference. The file name is AspNetPager. dll.
2. Add the <% @ RegisterAssembly = "AspNetPager" Namespace = "Wuqi. Webdiyer" TagPrefix = "webdiyer" %> code in the aspx file. The following is the paging style code:
3. Write using Wuqi. Webdiyer In the CS file;
4. obtain the data source. The following is a method to obtain the data, BLL. trunk. the GetAllList method is an encapsulated method that returns a DataSet result set. You can write this method by yourself. This is the code from the project:
View Code
1 private void LoadData ()
2 {
3 DataSet ds = BLL. Trunk. GetAllList ();
4 PagedDataSource PPS = newPagedDataSource ();
5 PPS. AllowPaging = true; // you can specify true to allow pagination.
6 PSP. DataSource = ds. Tables [0]. DefaultView; // you can specify a data source for pagination.
7 AspNetPager1.RecordCount = Pam. Count; // AspNetPager1.RecordCount = ds. Tables [0]. DefaultView. Count; equivalent // number of data records obtained
8 PPS. CurrentPageIndex = AspNetPager1.CurrentPageIndex-1; // you can specify the index of the current page.
9 PSP. PageSize = AspNetPager1.PageSize; // you can specify the number of pages displayed on each page.
10 gvData. DataSource = pds;
11 gvData. DataBind ();
12}
5. code change on the event page:
View Code
1 protected void AspNetPager1_PageChanging (object src, PageChangingEventArgs e)
2 {
3 this. aspNetPager1.CustomInfoHTML = string. format ("Current page {0}/{1} contains {2} records per page {3}", new object [] {this. aspNetPager1.CurrentPageIndex + 1, this. aspNetPager1.PageCount, this. aspNetPager1.RecordCount, this. aspNetPager1.PageSize });
4 AspNetPager1.CurrentPageIndex = e. NewPageIndex;
5 LoadData ();
6}
View Code
1 <div id = "PagerStyle">
2 <webdiyer: aspNetPager ID = "AspNetPager1" runat = "server" OnPageChanging = "Bandwidth" Width = "95%" PageSize = "20" AlwaysShow = "True" FirstPageText = "Homepage" LastPageText = "tail page "NextPageText =" Next "PrevPageText =" previous "ShowCustomInfoSection =" Left "ShowInputBox =" Never "CustomInfoTextAlign =" Right "CssClass =" paginator"
3 CurrentPageButtonClass = "cpb" CustomInfoHTML = "current section % CurrentPageIndex %/% PageCount % Total % PageCount % PAGE % PageSize % record" AlwaysShowFirstLastPageNumber = "True" LayoutType = Table "">
4 </webdiyer: AspNetPager>
5 </div>