一个简答的Access下的分页asp.net代码
程序员文章站
2024-03-08 18:30:40
复制代码 代码如下:public void listarticle() { cmsarticle arobj = new cmsarticle(); dataset ds...
复制代码 代码如下:
public void listarticle()
{
cmsarticle arobj = new cmsarticle();
dataset ds = arobj.listarticle();
if (ds != null)
{
pageddatasource pds = new pageddatasource();
pds.datasource = ds.tables[0].defaultview;
pds.allowpaging = true;
pds.pagesize = 1;
pds.currentpageindex = currentpage - 1;
rscount = ds.tables[0].rows.count;
pagecount = pds.pagecount;
pagesize = pds.pagesize;
gvnewlist.datasource = pds;
gvnewlist.databind();
///上下页
double result;
result = rscount / pagesize;
string[] r = new string[2];
r = result.tostring().split('.');
pagecount = convert.toint32(r[0]);
if (result > pagecount)
{
pagecount = pagecount + 1;
}
///上一页和首页
if (!pds.isfirstpage)
{
lnkprev.navigateurl = "?page=" + convert.tostring(currentpage - 1);
//lnkhead.navigateurl ="?page=" + convert.tostring(1);
}
///下一页和末页
if (!pds.islastpage)
{
lnknext.navigateurl = "?page=" + convert.tostring(currentpage + 1);
//lnkend.navigateurl = "?page=" + convert.tostring(rscount);
}
}
listinfolabel.text = "全部共" + rscount + "篇,每页" + pagesize + "篇,当前第" + currentpage + "/" + pagecount + "页";
pageinfoliteral.text = webapp.pagination.show(currentpage, pagecount, 10, "?page=", "");
}
上一篇: PHP7多线程搭建教程
下一篇: java发送短信系列之限制日发送次数