repeater分页 内容显示
更新时间:2006年10月13日 00:00:00 作者:
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 的摘要说明。
/// </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)
{
// 在此处放置用户代码以初始化页面
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 pds = new PagedDataSource();
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();
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </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();
}
}
}
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 的摘要说明。
/// </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)
{
// 在此处放置用户代码以初始化页面
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 pds = new PagedDataSource();
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();
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </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();
}
}
}
您可能感兴趣的文章:
- asp.net repeater手写分页实例代码
- asp.net Repeater之非常好的数据分页
- asp.net下Repeater使用 AspNetPager分页控件
- asp.net中让Repeater和GridView支持DataPager分页
- asp.net Repeater分页实例(PageDataSource的使用)
- Repeater控件与PagedDataSource结合实现分页功能
- asp.net中使用 Repeater控件拖拽实现排序并同步数据库字段排序
- 在ASP.NET 2.0中操作数据之四十二:DataList和Repeater数据排序(一)
- 在ASP.NET 2.0中操作数据之四十三:DataList和Repeater数据排序(二)
- 在ASP.NET 2.0中操作数据之四十四:DataList和Repeater数据排序(三)
相关文章
在ASP.NET 2.0中操作数据之二十八:GridView里的Button
本文主要介绍ASP.NET 2.0在GridView,DetailsView,FormView都可以包含Buttons,LinkButtons,或ImageButtons.这些button被点击时,并激发FormView和DetailsView的ItemCommand事件,GridView的RowCommand事件,根据CommandName的值来判断哪个button被点击了,执行相应的代码。2016-05-05ASP.NET中URL Routing和IIS上URL Rewriting的区别
这篇文章主要介绍了ASP.NET中URL Routing和IIS上URL Rewriting的区别,需要的朋友可以参考下。2016-06-06解读ASP.NET 5 & MVC6系列教程(8):Session与Caching
这篇文章主要介绍了ASP.NET 5 中的Session与Caching配置和使用,需要的朋友可以参考下2016-06-06在ASP.NET 2.0中操作数据之三十六:在DataList里编辑和删除数据概述
本文主要介绍如何使用DataList控件进行编辑和删除数数据的操作,感兴趣的朋友可以学习一下。2016-05-05在ASP.NET 2.0中操作数据之三十九:在DataList的编辑界面里添加验证控件
为了防止用户非法的输入,这节主要介绍如何在编辑数据的时候添加验证控件,以避免出现异常和保证数据的完整性。2016-05-05在MacOS+Linux+Nginx中发布和部署Asp.Net Core
这篇文章介绍了在MacOS+Linux+Nginx中发布和部署Asp.Net Core,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧2021-12-12
最新评论