. NET implement Repeater control +aspnetpager control pagination

Source: Internet
Author: User
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 ();

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.