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.