#region 数据显示
DataSet ds = new DataSet();
int allNum = messgeBll.GetRecordCount(" showType = 1 ");
int pageTotalNum = allNum / 30;
if ((allNum % pageTotalNum) > 0)
pageTotalNum++;
int currNum = 0;
int tmpStart = 0;//当前数据开始
int tmpEnd = 0;//当前数据结束
try
{
currNum = int.Parse(Request["num"].ToString());
}
catch { }
if (currNum.Equals(0))
{
tmpStart = 0;
tmpEnd = 29;
ds = messgeBll.GetListByPage(" showType = 1 ", "addtime", 0, 14);
messgeList = messgeBll.DataTableToList(ds.Tables[0]);
}
else
{
tmpStart = 30 * currNum;
tmpEnd = tmpStart + 30;
if (tmpEnd >= allNum)
tmpEnd = allNum - 1;
ds = messgeBll.GetListByPage(" showType = 1 ", "addtime", tmpStart, tmpEnd);
messgeList = messgeBll.DataTableToList(ds.Tables[0]);
}
#endregion
#region 分页导航
if (allNum > 30)
{
if (currNum > 0)
{
pagerStr.Append(string.Format(@"<a href=""/ext/MessageCenter.aspx?num={0}"">上一页</a> <a href=""/ext/MessageCenter.aspx?num={1}"">下一页</a> ", currNum - 1, currNum + 1));
}
else
{
pagerStr.Append(string.Format(@"<a href=""/ext/MessageCenter.aspx?num={0}"">上一页</a> <a href=""/ext/MessageCenter.aspx?num={1}"">下一页</a> ", 0, currNum + 1));
}
for (int i = 0; i < pageTotalNum; i++)
{
if (currNum.Equals(i))
pagerStr.Append(string.Format(@"<a href=""/ext/MessageCenter.aspx?num={0}""><b>{1}</b></a> ", i.ToString(), (i + 1).ToString()));
else
pagerStr.Append(string.Format(@"<a href=""/ext/MessageCenter.aspx?num={0}"">{1}</a> ", i.ToString(), (i + 1).ToString()));
}
}
#endregion
最近写的一个分页数据显示及分页导航
最新推荐文章于 2019-11-11 20:47:40 发布