Detailed description of ASP. Net paging Method

Source: Internet
Author: User

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>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.