ASP. NET paging Control Library

Source: Internet
Author: User
Tags connectionstrings

Aspnetpager Pagination Control

The Aspnetpager pagination control solves many of the problems in paging, using the control directly for paging, simplifying the tedious paging work, and here is the detailed code for how I use the Aspnetpager control for paging:
1. First download the latest AspNetPager.dll to www.webdiyer.com and add the reference directly to the VS2005.
2. Register the control on the page, introduce the control, and, of course, need to use a data carrier in the page, I'm using the Repeater control.

<%=AspnetpagerNamespace""=Webdiyer

<!--Omitted-

<Webdiyer:aspnetpagerId= "AspNetPager1"Runat= "Server"HorizontalAlign= "Right"Firstpagetext= "<<"Lastpagetext= ">>"Prevpagetext= "<"NextPageText= ">" numericbuttontextformatstring= "-{0}-"  width= "600px"

            showcustominfosection= "left" Span style= "color: #ff0000;" > showboxthreshold= "2"  pagesize= "5"   inputboxclass= "Text2"  textafterinputbox= ""  onpagechanging< Span style= "color: #0000ff;" >= "aspnetpager1_pagechanging"   />

3.cs Code

DataSet ds;
SqlDataAdapter Dr;
SqlCommand com;

ProtectedvoidPage_Load (Objectsender, EventArgs e)
{
If(!IsPostBack)
{
Stringstrconn=system.configuration.configurationmanager.connectionstrings["SperConnectionString1"]. ToString ();
SqlConnection Con=NewSqlConnection (strconn);
Con. Open ();
Com=NewSqlCommand ();
Com. Connection=Con
Com.commandtext="Select COUNT (*) from article";
Aspnetpager1.alwaysshow=True;
Aspnetpager1.pagesize=5;
Aspnetpager1.recordcount=(Int) com. ExecuteScalar ();
Con. Close ();
Repeaterdatabind ();
}
}
PrivatevoidRepeaterdatabind ()
{
Stringstrconn=system.configuration.configurationmanager.connectionstrings["SperConnectionString1"]. ToString ();
Dr=NewSqlDataAdapter ("SELECT * FROM article", strconn);
Ds=NewDataSet ();
Dr. Fill (DS, Aspnetpager1.pagesize*(Aspnetpager1.currentpageindex-1), Aspnetpager1.pagesize,"Article");
This. Repeater2.datasource=Ds. tables["Article"];
This. Repeater2.databind ();

}

ProtectedvoidAspnetpager1_pagechanging (ObjectSRC, Wuqi.Webdiyer.PageChangingEventArgs e)
{
Aspnetpager1.currentpageindex=E.newpageindex;
Repeaterdatabind ();
}
ProtectedStringFormatstring_size_13 (StringStr
{
If(str. Length> 33)
         {
             str = str. Substring (0, 32 )  +  ""         }
        return&NBSP;STR;
    }

4. The Pagechanging event for the last modification of the Aspnetpager control is aspnetpager1_pagechanging.

ASP. NET paging Control Library

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.