public static string BuildLinks(string Url, string QueryName, int PageNum, int PageTotal, int LinkSize, string DivAttr,string SpanAttr, string AAttr)
{
StringBuilder rtun = new StringBuilder();
rtun.Append("<div ");
rtun.Append(DivAttr);
rtun.Append(" >\n");
int pageNum = PageNum > 0 ? PageNum : 1;
int pageCount = PageTotal > 0 ? PageTotal : 1;
if (pageNum > pageCount) { pageNum = pageCount; }
int linkNum = LinkSize > 0 ? LinkSize : 1;
int pageStart = ((pageNum - 1) / linkNum) * linkNum + 1;
int pageEnd = pageStart + linkNum;
pageEnd = pageEnd > pageCount ? pageCount + 1 : pageEnd;
rtun.Append(ConcatAnchor(Url, AAttr, QueryName, "1", "首页"));
if (pageNum > 1)
{
rtun.Append(ConcatAnchor(Url, AAttr, QueryName, ((int)(pageNum - 1)).ToString(), "上一页"));
}
for (int i = pageStart; i < pageEnd; i++)
{
if (i == pageNum)
{
rtun.Append("<span "+SpanAttr+" >");
rtun.Append(i.ToString());
rtun.Append("</span>\n");
}
else
{
rtun.Append(ConcatAnchor(Url, AAttr, QueryName, i.ToString(), i.ToString()));
}
}
if (pageNum < pageCount)
{
rtun.Append(ConcatAnchor(Url, AAttr, QueryName, ((int)(pageNum+1)).ToString(), "下一页"));
}
rtun.Append(ConcatAnchor(Url, AAttr, QueryName, pageCount.ToString(), "末页"));
rtun.Append("</div>");
return rtun.ToString();
}
/*
* LZ:
* BuildLinks("/Ajax.aspx?Action=LoadList&","Page",i,33,10,"id=\"Cnic_Page_Tool\" class=\"PageBar\"","",null)
*
*/