开发工具:
文件大小: 46kb
下载次数: 0
上传时间: 2010-11-30
详细说明: Repeater分页显示 简单的说,先从控件工具箱中拖入两个label(currten page当前页,count page总页),四个linkbuttion(首/下页/上页/尾页)。 无非就是+1 -1 的问题, ------------------------ using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient; public partial class gonggao : System.Web.UI.UserControl { protected void Page_Load(object s ender, EventArgs e) { if (!IsPostBack) { this.labPage.Text = "1"; this.contrlRepeater(); } } //获取指字符个数的字符 public string cuts(string aa,int bb) { if (aa.Length <= bb) { return aa; } else { return aa.Substring(0, bb); } } //Repeater分页控制显示方法 public void contrlRepeater() { pb pb1 = new pb(); DataSet ss = new DataSet(); ss = pb1.returnDs("select top 200 [标题],[时间] from news"); PagedDataSource pds = new PagedDataSource(); pds.DataSource = ss.Tables["temptable"].DefaultView; pds.AllowPaging = true; pds.PageSize = 2; pds.CurrentPageIndex = Convert.ToInt32(this.labPage.Text) - 1; Repeater1.DataSource = pds; LabCountPage.Text = pds.PageCount.ToString(); labPage.Text = (pds.CurrentPageIndex + 1).ToString(); this.lbtnpritPage.Enabled = true; this.lbtnFirstPage.Enabled = true; this.lbtnNextPage.Enabled = true; this.lbtnDownPage.Enabled = true; if(pds.CurrentPageIndex<1) { this.lbtnpritPage.Enabled = false; this.lbtnFirstPage.Enabled = false; } if (pds.CurrentPageIndex == pds.PageCount-1) { this.lbtnNextPage.Enabled = false; this.lbtnDownPage.Enabled = false; } Repeater1.DataBind(); } protected void lbtnpritPage_Click(object sender, EventArgs e) { this.labPage.Text = Convert.ToString(Convert.ToInt32(labPage.Text) - 1); this.contrlRepeater(); } protected void lbtnFirstPage_Click(object sender, EventArgs e) { this.labPage.Text = "1"; this.contrlRepeater(); } protected void lbtnDownPage_Click(object sender, EventArgs e) { this.labPage.Text =this.LabCountPage.Text; this.contrlRepeater(); } protected void lbtnNextPage_Click(object sender, EventArgs e) { this.labPage.Text = Convert.ToString(Convert.ToInt32(labPage.Text) + 1); this.contrlRepeater(); } } ----------------- ...展开收缩
(系统自动生成,下载前可以参看下载内容)
下载文件列表
相关说明
- 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
- 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度。
- 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
- 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
- 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
- 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.