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




简单分页附:pb.returnds(根据sql语句返回dataset数据集.temptable表) 
简单分页
public dataset returnds(string sqlstr) 

相关文章:

  • 2021-05-11
  • 2021-09-21
  • 2022-12-23
  • 2022-12-23
  • 2022-01-02
  • 2022-12-23
  • 2019-07-23
猜你喜欢
  • 2021-12-04
  • 2021-10-16
  • 2021-10-20
  • 2021-10-07
  • 2021-08-05
  • 2021-07-04
相关资源
相似解决方案