repeater分页 内容显示

时间:2021-05-26

usingSystem;
usingSystem.Collections;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Web;
usingSystem.Web.SessionState;
usingSystem.Web.UI;
usingSystem.Web.UI.WebControls;
usingSystem.Web.UI.HtmlControls;
usingSystem.Data.OleDb;

namespacenote
{
///<summary>
///_default的摘要说明。
///</summary>
publicclass_default:System.Web.UI.Page
{
protectedSystem.Web.UI.WebControls.Repeaterrpt_sword_list;
protectedSystem.Web.UI.WebControls.Labellbl_count;
protectedSystem.Web.UI.WebControls.Labellbl_current_page;
protectedSystem.Web.UI.WebControls.Labellbl_total_page;
protectedSystem.Web.UI.WebControls.LinkButtonlb_frist;
protectedSystem.Web.UI.WebControls.LinkButtonlb_p;
protectedSystem.Web.UI.WebControls.LinkButtonlb_n;
protectedSystem.Web.UI.WebControls.LinkButtonlb_last;

privatevoidPage_Load(objectsender,System.EventArgse)
{
//在此处放置用户代码以初始化页面
if(!this.IsPostBack)
{
this.DB_Bind();
}
}

privatevoidDB_Bind()
{
intipageindex=Convert.ToInt32(this.lbl_current_page.Text);
OleDbConnectionconn=dbconn.CreateConn();
OleDbCommandcmd=newOleDbCommand("select*fromawhereflag=trueorderbycdatedesc",conn);
OleDbDataAdapteroda=newOleDbDataAdapter();
oda.SelectCommand=cmd;
DataSetds=newDataSet();
oda.Fill(ds,"sword_list");
PagedDataSourcepds=newPagedDataSource();
pds.DataSource=ds.Tables["sword_list"].DefaultView;
pds.AllowPaging=true;
pds.PageSize=5;
pds.CurrentPageIndex=ipageindex-1;
this.lbl_total_page.Text=pds.PageCount.ToString();
this.lbl_count.Text=pds.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==pds.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();
}

#regionWeb窗体设计器生成的代码
overrideprotectedvoidOnInit(EventArgse)
{
//
//CODEGEN:该调用是ASP.NETWeb窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

///<summary>
///设计器支持所需的方法-不要使用代码编辑器修改
///此方法的内容。
///</summary>
privatevoidInitializeComponent()
{
this.lb_frist.Click+=newSystem.EventHandler(this.lb_frist_Click);
this.lb_p.Click+=newSystem.EventHandler(this.lb_p_Click);
this.lb_n.Click+=newSystem.EventHandler(this.lb_n_Click);
this.lb_last.Click+=newSystem.EventHandler(this.lb_last_Click);
this.Load+=newSystem.EventHandler(this.Page_Load);

}
#endregion

privatevoidlb_frist_Click(objectsender,System.EventArgse)
{
this.lbl_current_page.Text="1";
this.DB_Bind();
}

privatevoidlb_p_Click(objectsender,System.EventArgse)
{
this.lbl_current_page.Text=Convert.ToString(Convert.ToInt32(this.lbl_current_page.Text)-1);
this.DB_Bind();
}

privatevoidlb_n_Click(objectsender,System.EventArgse)
{
this.lbl_current_page.Text=Convert.ToString(Convert.ToInt32(this.lbl_current_page.Text)+1);
this.DB_Bind();
}

privatevoidlb_last_Click(objectsender,System.EventArgse)
{
this.lbl_current_page.Text=this.lbl_total_page.Text;
this.DB_Bind();
}
}
}

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章