PagedDataSource data-bound controls and Aspnetpager pagination controls in combination with a list of pages

Source: Internet
Author: User

1, quote AspNetPager.dll.

2. Place the Repeater data-bound control.

<ID= "Repeater1"  runat= "Server">        <  ItemTemplate>    //binding the displayed list code         </  ItemTemplate>    </asp:repeater>

3. The following code appears when you add a Aspnetpager paging control to a page.

<%@ Register Assembly="Aspnetpager"Namespace="Wuqi.webdiyer"TagPrefix="Webdiyer" %>
<Webdiyer:aspnetpagerID= "AspNetPager1"CssClass= "Paginator"PageSize= "Ten"Alwaysshow= "true"Firstpagetext= "Home"Prevpagetext= "Previous page"NextPageText= "Next Page"CurrentPageIndex= "1"Lastpagetext= "Last"runat= "Server"onpagechanged= "Aspnetpager1_pagechanged">        </Webdiyer:aspnetpager>
// Double-click a paging control        protected void Aspnetpager1_pagechanged (object  sender, EventArgs e)        {    binddata ();        }

4.. cs file write bound data method.

 Public voidBinddata () {//here is the data source of the query, change this to have data. DataSet ds =NewDataSet (); //set up a paging data sourcePagedDataSource Pagesource =NewPagedDataSource (); Pagesource.allowpaging=true;//set whether to page outPagesource.pagesize = pagercontrol.pagesize;//Number of pagesPagesource.currentpageindex = Pagercontrol.currentpageindex-1;//This is the current page, do not decrement 1,pageddatasource is starting from 0. Pagesource.datasource = ds. table[0].            DefaultView; Pagercontrol.recordcount=Pagesource.datasourcecount; Repeater1.datasource=Pagersource;                   Repeater1.databind (); }
5. Results

PagedDataSource data-bound controls and Aspnetpager pagination controls in combination with a list of pages

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.