Example of resolving pagination. Binding to the DataList implementation using the DataSet. The database uses the one I just posted.

Source: Internet
Author: User
Paging | resolution | data | database using System;
Using System.Data;
Using System.Data.SqlClient;
Using System.Web;
Using System.Web.UI.WebControls;

Namespace Osleagueforumxp.admin
{
<summary>
Edit Bulletin Page
</summary>
public class EditBoardPage:System.Web.UI.Page
{
protected System.Web.UI.WebControls.HyperLink Hlkprev;
protected System.Web.UI.WebControls.HyperLink Hlknext;
protected System.Web.UI.WebControls.HyperLink Hlkfirst;
protected System.Web.UI.WebControls.HyperLink hlkend;
protected System.Web.UI.WebControls.Label lblpage;
protected System.Web.UI.WebControls.Panel Pelmain;
protected System.Web.UI.WebControls.Label lblmessage;
protected System.Web.UI.WebControls.HyperLink Hlkreturn;
protected System.Web.UI.WebControls.Panel pelmessage;
protected System.Web.UI.WebControls.DataList Dlboard;

private void Page_Load (object sender, System.EventArgs e)
{
Process clsprocess = new process ();
Clsprocess.common ();

const int PAGESIZE = 5;
int intpagecount;
int intpage;
if (request.querystring["Page"] = = null)
{
Intpage = 1;
}
Else
{
Intpage = Int32.Parse (request.querystring["Page");
}
int intstart = (intPage-1) * PAGESIZE;

SqlDataReader sqlreader = Clsprocess.getboardcount ();
if (Sqlreader.read ())
{
Intpagecount = (int) sqlreader["PageCount"];
}
Else
{
Intpagecount = 0;
}

int intallpage = (int) Math.floor (intpagecount/pagesize) + 1;

Dlboard.datasource = Clsprocess.getboard (intstart,pagesize);
Dlboard.databind ();

if (Clsprocess.getboard (intstart,pagesize). Count = 0)
{
Lblmessage.text = "Error occurred: <font color=\" red\ "> No announcements, please add Announcements </font>";
Hlkreturn.text = "Add announcement";
Pelmain.visible = false;
Pelmessage.visible = true;
}
Else
{
Lblpage.text = intallpage.tostring () + "/" + intpage.tostring ();

if (intallpage = 1)
{
Hlkfirst.navigateurl = "";
Hlkprev.navigateurl = "";
Hlknext.navigateurl = "";
Hlkend.navigateurl = "";
}
else if (intpage = 1)
{
Hlkfirst.navigateurl = "";
Hlkprev.navigateurl = "";
Hlknext.navigateurl = "Editboard.aspx?" Page= "+ (intpage + 1);
Hlkend.navigateurl = "Editboard.aspx?" Page= "+ intallpage;
}
else if (intpage = = intallpage)
{
Hlkfirst.navigateurl = "Editboard.aspx?" Page=1 ";
Hlkprev.navigateurl = "Editboard.aspx?" Page= "+ (intPage-1);
Hlknext.navigateurl = "";
Hlkend.navigateurl = "";
}
Else
{
Hlkfirst.navigateurl = "Editboard.aspx?" Page=1 ";
Hlkprev.navigateurl = "Editboard.aspx?" Page= "+ (intPage-1);
Hlknext.navigateurl = "Editboard.aspx?" Page= "+ (intpage + 1);
Hlkend.navigateurl = "Editboard.aspx?" Page= "+ intallpage;
}
}
}

#region Web Form Designer generated code
Override protected void OnInit (EventArgs e)
{
//
CodeGen: This call is required for the ASP.net Web forms Designer.
//
InitializeComponent ();
Base. OnInit (e);
}

<summary>
Designer supports required methods-do not use the Code editor to modify
The contents of this method.
</summary>
private void InitializeComponent ()
{
This. Load + = new System.EventHandler (this. Page_Load);

}
#endregion
}
}


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.