日期:2014-05-17 浏览次数:20887 次
public void Paging(int totalrecord, int PageSize, int DigitNo, Control pagediv, Repeater rpt,string table,string id)
{
int CurrentPage, PageStart, PageEnd, TotalPage;
//****************************************//计算总页数
int pn1 = totalrecord / PageSize, pn2 = totalrecord % PageSize;
if (pn2 != 0)
TotalPage = pn1 + 1;
else
if (pn1 == 0)
TotalPage = 1;
else
TotalPage = pn1;
//****************************************
if (Request.QueryString["page"] == null)//获取当前页码
CurrentPage = 1;
else
CurrentPage = Convert.ToInt16(Request.QueryString["page"]);
PageStart = 1;//起始数字逻辑判断
if (CurrentPage >= DigitNo + 2)
PageStart = CurrentPage - DigitNo;
PageEnd = CurrentPage + DigitNo;//结束数字逻辑判断
if (PageEnd > TotalPage + 1)
PageEnd = TotalPage + 1;
if (CurrentPage != 1)
{
HyperLink FP = new HyperLink();//生成首页文字按钮
FP.Text = "首页"; FP.Style["color"] = "#06C";
FP.NavigateUrl = "?page=1";
HyperLink PP = new HyperLink();//生成上一页文字按钮
PP.Text = "上一页"; PP.Style["color"] = "#06C";
PP.NavigateUrl = "?page=" + (CurrentPage - 1);
&n