Repeater page content display

Source: Internet
Author: User

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 ();
}
}
}

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.