分页对 首页,上一页,下一页,尾页按钮的处理
#region 分页对 首页,上一页,下一页,尾页按钮的处理
///
/// 搜索的关键字命名
/// 要搜索的关键字
/// 当前页的数字
/// 每页要显示的数目
/// 记录总数
private void BindPager(string flag, string keyword, int currentPage, int pageSize, int viewCount)
{
string hrf = "{1}";
int pageCount = 1;
if (viewCount > pageSize)
{
pageCount = (viewCount % pageSize) == 0 ? (viewCount / pageSize) : (viewCount / pageSize + 1);
LbFirstPage.Text = (pageCount > 0) ? string.Format(hrf, 1, "首页") : "首页"; LbFirstPage.Enabled = (pageCount > 0) ? true : false;
LbPre.Text = (currentPage > 1) ? string.Format(hrf, currentPage - 1, "上一页") : "上一页";
LbPre.Enabled = (currentPage > 1) ? true : false;
LbNext.Text = (currentPage + 1) <= pageCount ? string.Format(hrf, currentPage + 1, "下一页") : "下一页";
LbNext.Enabled = (currentPage + 1) <= pageCount ? true : false;
LbLastPage.Text = (pageCount > 0) ? string.Format(hrf, pageCount, "末页") : "末页";
LbLastPage.Enabled = (pageCount > 0) ? true : false;
}
else
{ LbFirstPage.Text = string.Format(hrf, 1, "首页");
LbPre.Enabled = false;
LbNext.Enabled = false;
LbLastPage.Enabled = false;
}
LbRecordCount.Text = viewCount.ToString();
LbcurrenPage.Text = currentPage.ToString();
LbpageCount.Text = pageCount.ToString();
LbRecords.Text = viewCount.ToString();
if (currentPage == pageCount)
{
LbLastPage.Enabled = false;
LbNext.Enabled = false;
}
} #endregion