Using System;
Using System. Collections;
Using System. ComponentModel;
Using System. Data;
Using System. Drawing;
Using System. Web;
Using System. Web. SessionState;
Using System. Web. UI;
Using System. Web. UI. WebControls;
Using System. Web. UI. HtmlControls;
Using System. Data. OleDb;
Namespace note
{
/// <Summary>
/// _ Default abstract description.
/// </Summary>
Public class _ default: System. Web. UI. Page
{
Protected System. Web. UI. WebControls. Repeater rpt_sword_list;
Protected System. Web. UI. WebControls. Label lbl_count;
Protected System. Web. UI. WebControls. Label lbl_current_page;
Protected System. Web. UI. WebControls. Label lbl_total_page;
Protected System. Web. UI. WebControls. LinkButton lb_frist;
Protected System. Web. UI. WebControls. LinkButton lb_p;
Protected System. Web. UI. WebControls. LinkButton lb_n;
Protected System. Web. UI. WebControls. LinkButton lb_last;
Private void Page_Load (object sender, System. EventArgs e)
{
// Place user code here to initialize the page
If (! This. IsPostBack)
{
This. DB_Bind ();
}
}
Private void DB_Bind ()
{
Int ipageindex = Convert. ToInt32 (this. lbl_current_page.Text );
OleDbConnection conn = dbconn. CreateConn ();
OleDbCommand cmd = new OleDbCommand ("select * from a where flag = true order by cdate desc", conn );
OleDbDataAdapter oda = new OleDbDataAdapter ();
Oda. SelectCommand = cmd;
DataSet ds = new DataSet ();
Oda. Fill (ds, "sword_list ");
PagedDataSource PPS = new PagedDataSource ();
Pds. DataSource = ds. Tables ["sword_list"]. DefaultView;
PPS. AllowPaging = true;
PPS. PageSize = 5;
PPS. CurrentPageIndex = ipageindex-1;
This. lbl_total_page.Text = maid. PageCount. ToString ();
This. lbl_count.Text = maid. Count. ToString ();
This. lb_frist.Enabled = true;
This. lb_p.Enabled = true;
This. lb_n.Enabled = true;
This. lb_last.Enabled = true;
If (this. lbl_current_page.Text = "1 ")
{
This. lb_frist.Enabled = false;
This. lb_p.Enabled = false;
}
If (this. lbl_current_page.Text = PPS. PageCount. ToString ())
{
This. lb_n.Enabled = false;
This. lb_last.Enabled = false;
}
This. rpt_sword_list.DataSource = pds;
This. rpt_sword_list.DataBind ();
Conn. Close ();
}
# Code generated by region Web Form Designer
Override protected void OnInit (EventArgs e)
{
//
// CODEGEN: This call is required by the ASP. NET Web form designer.
//
InitializeComponent ();
Base. OnInit (e );
}
/// <Summary>
/// The designer supports the required methods-do not use the code editor to modify
/// Content of this method.
/// </Summary>
Private void InitializeComponent ()
{
This. lb_frist.Click + = new System. EventHandler (this. lb_frist_Click );
This. lb_p.Click + = new System. EventHandler (this. lb_p_Click );
This. lb_n.Click + = new System. EventHandler (this. lb_n_Click );
This. lb_last.Click + = new System. EventHandler (this. lb_last_Click );
This. Load + = new System. EventHandler (this. Page_Load );
}
# Endregion
Private void lb_frist_Click (object sender, System. EventArgs e)
{
This. lbl_current_page.Text = "1 ";
This. DB_Bind ();
}
Private void lb_p_Click (object sender, System. EventArgs e)
{
This. lbl_current_page.Text = Convert. ToString (Convert. ToInt32 (this. lbl_current_page.Text)-1 );
This. DB_Bind ();
}
Private void lb_n_Click (object sender, System. EventArgs e)
{
This. lbl_current_page.Text = Convert. ToString (Convert. ToInt32 (this. lbl_current_page.Text) + 1 );
This. DB_Bind ();
}
Private void lb_last_Click (object sender, System. EventArgs e)
{
This. lbl_current_page.Text = this. lbl_total_page.Text;
This. DB_Bind ();
}
}
}