protected int getCount()
{
//设置总数据行.
int sum = lqc.Photo_Category.Count();
labPageCount.Text = sum.ToString();
//获取可以分的页面
int s1 = sum / pageSize;
//当总行数对页数求余后是否大于0,如果大于获取1否则获取0
int s2 = sum % pageSize > 0 ? 1 : 0;
//计算出总页数
int count = s1 + s2;
return count;
}
protected void lnkbtnUp_Click(object sender, EventArgs e)
{
//设置当前页数为当前页数减一
ViewState["pageIndex"] = Convert.ToInt32(ViewState["pageIndex"]) - 1;
//调用自定义bindGrid方法绑定GridView控件
BindGV();
}
protected void lnkbtnDown_Click(object sender, EventArgs e)
{
//设置当前页数为当前页数加一
ViewState["pageIndex"] = Convert.ToInt32(ViewState["pageIndex"]) + 1;
//调用自定义bindGrid方法绑定GridView控件
BindGV();
}
protected void lnkbtnBottom_Click(object sender, EventArgs e)
{
//设置当前页数为总页面减一
ViewState["pageIndex"] = getCount() - 1;
//调用自定义bindGrid方法绑定GridView控件
BindGV();
}

本文介绍了一个基于ASP.NET的分页查询实现方法,包括计算总页数、上一页、下一页和跳转到最后一页的功能。通过获取总数据行数并根据设定的页面大小计算页数,实现了对数据的有效分页展示。

被折叠的 条评论
为什么被折叠?



