How to Use the ASPNETPAGER paging Control

Source: Internet
Author: User

1. This is required to add a dll file.
2. Drag the control to the application location and add reference:
Reference:

<% @ Register Assembly = "AspNetPager" Namespace = "Wuqi. Webdiyer" TagPrefix = "webdiyer" %>

Controls:

Copy codeThe Code is as follows:
<Div style = "text-align: center;">
<Webdiyer: AspNetPager ID = "AspNetPagerAskAnswer" runat = "server"
AlwaysShow = "True" FirstPageText = "Homepage" LastPageText = "last page" NextPageText = "next page"
Onpagechanged = "AspNetPagerAskAnswer_PageChanged" PrevPageText = "Previous Page"
PageSize = "15">
</Webdiyer: AspNetPager>
<Br/>
</Div>


(There is a quick and easy way to display the next page on the homepage)

The front-end is basically done here, that is, the background code is compiled:
Copy codeThe Code is as follows:
Private void bind () {SqlConnection connection = new SqlConnection (ConfigurationManager. ConnectionStrings ["tianzi"]. ConnectionString );
SqlCommand cmd = new SqlCommand ("select * from ask", connection );
SqlDataAdapter sda = new SqlDataAdapter (cmd );
DataSet ds = new DataSet ();
AspNetPagerAskAnswer. PageSize = 5; // set the page size
AspNetPagerAskAnswer. RecordCount = AskManager. GetAllAsks (). Rows. Count; // you can specify the total number of data entries.
Sda. Fill (ds, AspNetPagerAskAnswer. PageSize * (AspNetPagerAskAnswer. CurrentPageIndex-1), AspNetPagerAskAnswer. PageSize, "asks"); // fixed
RepeaterAskAnswer. DataSource = ds. Tables ["asks"];
RepeaterAskAnswer. DataBind ();
}


It is okay to write it here, but clicking the page turns to find that the data is the same. Why? We did forget one thing:
Copy codeThe Code is as follows:
Protected void AspNetPagerAskAnswer_PageChanged (object sender, EventArgs e)
{
Bind ();
}

It's almost done here!

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.