asp.net分页代码
要分页代码不要上一页下一页的要123456那样显示的详细点的最好带注释本人新手谢谢各位大虾~~~...
要分页代码 不要上一页下一页的 要1 2 3 4 5 6那样显示的 详细点的 最好带注释 本人新手 谢谢各位大虾~~~
展开
3个回答
展开全部
/// <summary>
/// 分页代码
/// </summary>
/// <param name="url">页面URL</param>
/// <param name="page">当前页面</param>
/// <param name="allPage">共多少页</param>
/// <param name="allCount">共多少条记录</param>
/// <param name="PageCount">每页显示多少条记录</param>
/// <returns></returns>
public string goPage(string url, int page, int allPage, int allCount, int PageCount)
{
int startPage = page - 3;
int endPage = page + 3;
if (startPage < 1)
startPage = 1;
if (endPage > allPage)
endPage = allPage;
string strHtml = "";
string fh = "&";
if (url.IndexOf("?") > -1)
fh = "&";
else
fh = "?";
//strHtml = "共:"+
strHtml = "共:" + allCount + " 条记录,每页显示:" + PageCount + "条,当前" + page + "/" + allPage + "页 <a href=\"" + url + fh + "page=1\">第一页</a> ";
for (int i = startPage; i <= endPage; i++)
{
if (i.Equals(page))
strHtml += "<b><font color=\"red\">" + i + "</font></b> ";
else
strHtml += "[<a href=\"" + url + fh + "page=" + i + "\">" + i + "</a>] ";
}
strHtml += "<a href=\"" + url + fh + "page=" + allPage + "\">最后页</a>";
return strHtml;
}
/// 分页代码
/// </summary>
/// <param name="url">页面URL</param>
/// <param name="page">当前页面</param>
/// <param name="allPage">共多少页</param>
/// <param name="allCount">共多少条记录</param>
/// <param name="PageCount">每页显示多少条记录</param>
/// <returns></returns>
public string goPage(string url, int page, int allPage, int allCount, int PageCount)
{
int startPage = page - 3;
int endPage = page + 3;
if (startPage < 1)
startPage = 1;
if (endPage > allPage)
endPage = allPage;
string strHtml = "";
string fh = "&";
if (url.IndexOf("?") > -1)
fh = "&";
else
fh = "?";
//strHtml = "共:"+
strHtml = "共:" + allCount + " 条记录,每页显示:" + PageCount + "条,当前" + page + "/" + allPage + "页 <a href=\"" + url + fh + "page=1\">第一页</a> ";
for (int i = startPage; i <= endPage; i++)
{
if (i.Equals(page))
strHtml += "<b><font color=\"red\">" + i + "</font></b> ";
else
strHtml += "[<a href=\"" + url + fh + "page=" + i + "\">" + i + "</a>] ";
}
strHtml += "<a href=\"" + url + fh + "page=" + allPage + "\">最后页</a>";
return strHtml;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询