Based on the AspNetPage, this article introduces various popular paging methods, such as the use of custom aspnetpage controls such as the thunder style and Netease style.
There is no eternal success in confession. I. Binding method
Private void DataBindDataTable (string whereCondition) {// whereCondition is the prerequisite for querying
IList <Sr_TakeNameListEntity> list = SrTakeNameListManage. GetSrTabkeNameAllList (whereCondition );
AspNetPager1.RecordCount = list. Count; // you can specify the total number of entries.
The Code is as follows: |
Copy code |
|
The most painful thing in life is waking up with no way to go. A dreamer is happy. If there is no way to go, the most important thing is not to wake him up.
The Code is as follows: |
Copy code |
PagedDataSource PPS = new PagedDataSource (); PPS. DataSource = list; PPS. AllowPaging = true; PPS. CurrentPageIndex = AspNetPager1.CurrentPageIndex-1; // index of the current page PPS. PageSize = AspNetPager1.PageSize; // number of records displayed on each page GridView1.DataSource = pds; GridView1.DataBind (); } |
Ii. Initial page loading
The Code is as follows: |
Copy code |
If (! IsPostBack ){ ViewState ["vkey"] = "1 = 1"; // query the prerequisite keyword DataBindDataTable (ViewState ["vkey"]. ToString ()); } |
Iii. AspNetPage transactions
The Code is as follows: |
Copy code |
Protected void AspNetPager1_PageChanged (object sender, EventArgs e) { DataBindDataTable (ViewState ["vkey"]. ToString ()); } |
4. Search button and click transaction
The Code is as follows: |
Copy code |
Protected void btnAllSearch_Click (object sender, EventArgs e) { AspNetPager1.CurrentPageIndex = 1; ViewState ["vkey"] = "1 = 1 "; DataBindDataTable (ViewState ["vkey"]. ToString ()); } |
<H4> Netease style:
The Code is as follows: |
Copy code |
<Webdiyer: AspNetPager CssClass = "anpager" CurrentPageButtonClass = "cpb" ID = "AspNetPager2" runat = "server" RecordCount = "228" FirstPageText = "Homepage" LastPageText = "last page" NextPageText = "last page" PrevPageText = "Previous Page"> </Webdiyer: AspNetPager> |
/* Netease style */
The Code is as follows: |
Copy code |
. Anpager. ECC {background: #1F3A87 none repeat scroll 0 0; border: 1px solid # CCCCCC; color: # FFFFFF; font-weight: bold; margin: 5px 4px 0 0 0; padding: 4px 5px 0 ;} . Anpager a {background: # FFFFFF none repeat scroll 0 0; border: 1px solid # CCCCCC; color: #1F3A87; margin: 5px 4px 0 0; padding: 4px 5px 0; text-decoration: none} . Anpager a: hover {background: #1F3A87 none repeat scroll 0 0; border: 1px solid #1F3A87; color: # FFFFFF ;} |
<H4> Pat network style:
The Code is as follows: |
Copy code |
<Webdiyer: AspNetPager CssClass = "paginator" CurrentPageButtonClass = "cpb" ID = "AspNetPager3" runat = "server" RecordCount = "228" FirstPageText = "Homepage" LastPageText = "last page" NextPageText = "next page" PrevPageText = "Previous Page"> |
/* Pat network style */
The Code is as follows: |
Copy code |
. Paginator {font: 11px Arial, Helvetica, sans-serif; padding: 10px 20px 10px 0; margin: 0px ;} . Paginator a {padding: 1px 6px; border: solid 1px # ddd; background: # fff; text-decoration: none; margin-right: 2px} . Paginator a: visited {padding: 1px 6px; border: solid 1px # ddd; background: # fff; text-decoration: none ;} . Paginator. ECC {padding: 1px 6px; font-weight: bold; font-size: 13px; border: none} . Paginator a: hover {color: # fff; background: # ffa501; border-color: # ffa501; text-decoration: none ;} |
<H4> thunder style:
The Code is as follows: |
Copy code |
<Webdiyer: AspNetPager CssClass = "pages" CurrentPageButtonClass = "cpb" ID = "AspNetPager4" runat = "server" RecordCount = "228" FirstPageText = "Homepage" LastPageText = "last page" NextPageText = "next page" PrevPageText = "Previous Page"> </Webdiyer: AspNetPager> |
/* Thunder style */
The Code is as follows: |
Copy code |
. Pages {color: #999} . Pages ,. pages. cpb {text-decoration: none; float: left; padding: 0 5px; border: 1px solid # ddd; background: # ffff; margin: 0 2px; font-size: 11px; color: #000 ;} . Pages a: hover {background-color: # E61636; color: # fff; border: 1px solid # E61636; text-decoration: none ;} . Pages. ECC {font-weight: bold; color: # fff; background: # E61636; border: 1px solid # E61636 ;} . Code {font-weight: bold; color: blue}
|