asp.net control DataList Pagination Usage _ Practical Tips

Source: Internet
Author: User

The example in this article describes the ASP.net control DataList paging usage. Share to everyone for your reference, specific as follows:

protected void Page_Load (object sender, EventArgs e) {if (!
   IsPostBack) {viewstate["Page"] = 0;
  Bangding ();
  }//Binding Data public void bangding () {PagedDataSource PDS = new PagedDataSource (); Pds.
  DataSource = Merchandisemanager.getlist (""); Pds.
  AllowPaging = true; Pds. PageSize = 5; The number of records per page PDS. CurrentPageIndex = pager;//Current Page Lblcurrpage.text = "First" + (PDS. CurrentPageIndex + 1). ToString () + "page Total" + PDS.
  Pagecount.tostring () + "page";
  Setenable (PDS);//The effective strong state of the upper and lower page buttons Dlistmerchand.datasource = PDS;
Dlistmerchand.databind ();
  private int Pager {get {return (int) viewstate["Page"];
  The set {viewstate["Page"] = value;
  }//Next page protected void LinkButton1_Click (object sender, EventArgs e) {pager++;
Bangding ();
  //previous page protected void Linkbutton2_click (object sender, EventArgs e) {pager--;
Bangding ();
  }///page button effective strong state private void setenable (PagedDataSource pds) {btnshang.enabled = true;
  Btnxia.enabled = true; if (PDS. Isfirstpage) {BtnshAng.
  Enabled = false; } if (PDS.
  Islastpage) {btnxia.enabled = false;

 }
}

More interested readers of asp.net related content can view the site topics: "asp.net string operation tips Summary", "ASP.net Operation XML Skills summary", "asp.net file Operation skills Summary", "ASP.net Ajax Skills Summary topics" and " Summary of ASP.net caching operation techniques.

I hope this article will help you to ASP.net program design.

Related Article

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.