First of all, you have to put the bin file in your project and add it to your toolbar.
Page Header reference <%@ Register assembly= "Aspnetpager" namespace= "Wuqi.webdiyer" tagprefix= "Webdiyer"%> Control section (format is already designed) <webdiyer:aspnetpager id= "AspNetPager1" runat= "Server" alwaysshow= "True" firstpagetext= "<font face= ' webdings ' >9</font> "lastpagetext=" <font face= ' webdings ' >:</font> "nextpagetext=" <font face= ' Webdings ' >8</font> ' prevpagetext= ' <font face= ' webdings ' >7</font> ' showcustominfosection= ' Left "inputboxstyle=" width:19px "textafterinputbox=" page "textbeforeinputbox=" Go to section "custominfohtml=" Retrieved <strong> %recordcount%</strong> Records page:<strong>%currentpageindex%/%pagecount%</strong> per page <strong>% Pagesize%</strong> "horizontalalign=" right "width=" 100% "showinputbox=" Always "onpagechanged=" AspNetPager1_ Pagechanged "pagesize=" showboxthreshold= "1" ></webdiyer:AspNetPager>
Code for background bindings
void DataBind () { int qyid = Convert.ToInt32 (request.cookies["Compenyuser"]. Value);//The ID of the enterprise DataTable dt = BLL. Viewlist (Qyid); This. Aspnetpager1.recordcount = dt. rows.count;//Total Data acquisition PagedDataSource PDS = new PagedDataSource (); Pds. DataSource = dt. defaultview;//binds the data PDS for the control . AllowPaging = true;//paging Enable PDS. PageSize = aspnetpager1.pagesize;//Gets the number of PDS displayed per page . CurrentPageIndex = aspnetpager1.currentpageindex-1; Repeater1.datasource = PDS; Repeater1.databind (); }
Paging, just put the bindings in the Aspnetpager1_pagechanged event
Give us one more example.
Front page code
<%@ page language= "C #" autoeventwireup= "true" codefile= "TF_Product.aspx.cs" inherits= "tf_product"%> <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <%@ Register assembly=" Aspnetpager "namespace=" Wuqi.webdiyer "tagprefix=" Webdiyer "%>
Background code
Tb_productshelper helper = new Tb_productshelper (); ilist<tb_productsinfo> list = helper. Getalllistbysql (product_sql); This. Aspnetpager1.recordcount = list. count;//total number of bindings this . Aspnetpager1.alwaysshow = true; First declare a paging class object PagedDataSource PS = new PagedDataSource (); Ps. AllowPaging = true; Ps. PageSize = this. Aspnetpager1.pagesize; Ps. CurrentPageIndex = this. aspnetpager1.currentpageindex-1; Ps. DataSource = list; This.rp.DataSource = PS; This.rp.DataBind ();