欢迎来到天天文库
浏览记录
ID:38468067
大小:29.50 KB
页数:4页
时间:2019-06-13
《Repeater分页显示》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、Repeater分页显示简单的说,先从控件工具箱中拖入两个label(currtenpage当前页,countpage总页),四个linkbuttion(首/下页/上页/尾页)。无非就是+1-1的问题,------------------------usingSystem;usingSystem.Data;usingSystem.Configuration;usingSystem.Collections;usingSystem.Web;usingSystem.Web.Security;usingSystem.Web.UI;usingSystem.Web.UI.W
2、ebControls;usingSystem.Web.UI.WebControls.WebParts;usingSystem.Web.UI.HtmlControls;usingSystem.Data.SqlClient;publicpartialclassgonggao:System.Web.UI.UserControl{protectedvoidPage_Load(objectsender,EventArgse){if(!IsPostBack){this.labPage.Text="1";this.contrlRepeater();}}//获取指字符个数的字符
3、publicstringcuts(stringaa,intbb){if(aa.Length<=bb){returnaa;}else{returnaa.Substring(0,bb);}}//Repeater分页控制显示方法publicvoidcontrlRepeater(){pbpb1=newpb();DataSetss=newDataSet();ss=pb1.returnDs("selecttop200[标题],[时间]fromnews");PagedDataSourcepds=newPagedDataSource();pds.DataSource=ss.Ta
4、bles["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.lbtnFir
5、stPage.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;}Re
6、peater1.DataBind();}protectedvoidlbtnpritPage_Click(objectsender,EventArgse){this.labPage.Text=Convert.ToString(Convert.ToInt32(labPage.Text)-1);this.contrlRepeater();}protectedvoidlbtnFirstPage_Click(objectsender,EventArgse){this.labPage.Text="1";this.contrlRepeater();}protectedvoid
7、lbtnDownPage_Click(objectsender,EventArgse){this.labPage.Text=this.LabCountPage.Text;this.contrlRepeater();}protectedvoidlbtnNextPage_Click(objectsender,EventArgse){this.labPage.Text=Convert.ToString(Convert.ToInt32(labPage.Text)+1);this.contrlRepeater();}}---------------------------
8、------------
此文档下载收益归作者所有