1.定义三个变量:a.当前第几页数currentPage,b.显示多少条pageSize,c.总页数sumPage
2.sql代码(select top pageSize * from 表 where Id not in (select currentPage*pageSize Id from 表 order by Id)order by Id)
3.计算总页数代码:
public int MyCalculator(){
//调用数据库的方法查询总条数count;
if(count%pageSize>0)
{
sumPage=count/pageSize+1;
}
else
{
sumPage=count/pageSize;
}
}
4.上一页currentPage--;下一页currentPage++;首页currentPage=0;末页currentPage=sumPage;
5.注意:每次翻页后记得将数据绑定