. NET implementation Repeater Control +aspnetpager control pagination _ Practical Tips

Source: Internet
Author: User

Of course, first you have to put the bin file into your project, and add to your toolbar to

The page header needs to be referenced by the
<%@ Register assembly= "Aspnetpager" namespace= "Wuqi.webdiyer" tagprefix= "Webdiyer"%>

Control Section (format is already well designed)
<webdiyer:aspnetpager id= "AspNetPager1" runat= "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 the "custominfohtml=" to retrieve the <strong>%RecordCount%</strong> Records page times: <strong>%currentpageindex%/% Pagecount%</strong> per page <strong>%PageSize%</strong> "
 horizontalalign=" "Right" width= "100%" showinputbox= "Always" onpagechanged= "aspnetpager1_pagechanged"
 pagesize= "1" >
</webdiyer:AspNetPager>

background-bound Code

void DataBind ()
    {
      int qyid = Convert.ToInt32 (request.cookies["Compenyuser"). Value);//Enterprise's id
      DataTable dt = BLL. Viewlist (Qyid);
      This. Aspnetpager1.recordcount = dt. rows.count;//get the total number of data

      pageddatasource PDS = new PagedDataSource ();
      Pds. DataSource = dt. defaultview;//binds the data PDS to the control
      . AllowPaging = true;//To enable PDS for paging
      . PageSize = aspnetpager1.pagesize;//Gets the quantity PDS per page display
      . CurrentPageIndex = aspnetpager1.currentpageindex-1;

      Repeater1.datasource = PDS;
      Repeater1.databind ();
    }

Pagination, just put the binding in the Aspnetpager1_pagechanged event

And give you an 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. Total number of count;//bindings this
    . Aspnetpager1.alwaysshow = true;
    First declare a page-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.