手机
当前位置:查字典教程网 >编程开发 >asp.net教程 >repeater分页 内容显示
repeater分页 内容显示
摘要:usingSystem;usingSystem.Collections;usingSystem.ComponentModel;usingSy...

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

}

}

}

【repeater分页 内容显示】相关文章:

asp.net membership 密码重设

asp.net aspnetpager分页统计时与实际不符的解决办法

浅谈VS中的DataPager分页

Repeater事件OnItemCommand取得行内控件的方法

页面包含的处理

list泛型自定义排序示例

Repeater控件与PagedDataSource结合实现分页功能

.Net 文本框实现内容提示的实例代码

asp.net repeater实现批量删除时注册多选框id到客户端

asp.net Repeater绑定时使用函数

精品推荐
分类导航