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