private string CreatePage(int resultCount, int PageIndex, string keyWord, string cdoc_type, string cpush_date)
{
int count;
string ChannelCode = Request["ChannelCode"];
//如果查询结果总数是页大小的整数倍
keyWord = Server.UrlEncode(keyWord);
cdoc_type = Server.UrlEncode(cdoc_type);
cpush_date = Server.UrlEncode(cpush_date);
if (resultCount % PageSize == 0)
{
count = resultCount / PageSize;
//PageCount.Text = count.ToString();
}
else
{
count = resultCount / PageSize + 1;
//PageCount.Text = count.ToString();
}
//分页显示的控制
string URLpara = "&keyWord=" + keyWord + "&ChannelCode=" + ChannelCode + "&cdoc_type=" + cdoc_type + "&cpush_date=" + cpush_date + "&_T=1";
string DivPageString = "共" + pageCount.ToString() + "页";
//显示<上一页>
if (PageIndex > 1)
{
DivPageString = DivPageString + " <a href=\"DiySearch.aspx?page=" +
(PageIndex - 1).ToString()
+ URLpara
+ "\">上一页</a>";
}
//显示当前页的面前几页
//
for (int i = PageIndex - DivPageIndex; i <= PageIndex - 1; i++)
{
DivPageString = DivPageString + " <a href=\"DiySearch.aspx?page=" +
i.ToString()
+ URLpara
+ "\">[" +
i.ToString()
+ "]</a>";
}
//显示当前页
DivPageString = DivPageString + " <font color='#FF0000'>[" + PageIndex.ToString() + "]</font>";
//显示当前页的后前几页
for (int i = PageIndex + 1; i <= PageIndex + 5; i++)
{
if (i > count) { break; }
DivPageString = DivPageString + " <a href=\"DiySearch.aspx?page=" +
i.ToString()
+ URLpara
+ "\">[" +
i.ToString()
+ "]</a>";
}
//显示<下一页>
if (PageIndex < count)
{
DivPageString = DivPageString + " <a href=\"DiySearch.aspx?page=" +
(PageIndex + 1).ToString()
+ URLpara
+ "\">下一页</a>";
}
return DivPageString;
}