c#分页代码

c#分页代码,第1张

那个东西要自己写。。

我写了一个,挺复杂的。。。

给你做参考吧。。。。

<%

//分页

int allWriteBackForumNum = AllDataWorkTitle.WriteBackFroumNum(forumTitleId) //得到全部回帖数量,分页用

int maxPageNum = allWriteBackForumNum / 10 + 1

if (allWriteBackForumNum % 10 == 0 &&allWriteBackForumNum != 0) //如果回帖数量是10的倍数,减去最后那个空页

{

maxPageNum = maxPageNum - 1

}

Response.Write("         ")//输出写空格

Response.Write("共" + (allWriteBackForumNum - 1).ToString() + "楼")

//输出页数并且都加上链接而且页数多的话,显示部分(花线内)

//************************************************************************************************************

Response.Write("    ")

if (allWriteBackForumNum != 0 &&maxPageNum <= 10)

{

for (int j = 1j <= maxPageNumj++)

{

if (j == pageNum)

{

Response.Write("    <font color = red>[" + j.ToString() + "]</font>    ")

}

else

{

string ee = "<a href=ForumPage.aspx?MclassId=" + mClassId + "&NclassId=" + nClassId + "&BrandId=" + brandId

+ "&ProductId=" + productId + "&ForumTitleId=" + forumTitleId + "&pageNum=" + j.ToString() + ">[" + j.ToString() + "]</a>"

Response.Write("    " + ee + "    ")

}

}

Response.Write("<br>")

}

else if (maxPageNum >10)

{

if (pageNum == 1)

{

for (int j = 1j <= 10j++)

{

if (j == pageNum)

{

Response.Write("    <font color = red>[" + j.ToString() + "]</font>     ")

}

else

{

string ee = "<a href=ForumPage.aspx?MclassId=" + mClassId + "&NclassId=" + nClassId + "&BrandId=" + brandId + "&ProductId=" +

productId + "&ForumTitleId=" + forumTitleId + "&pageNum=" + j.ToString() + ">[" + j.ToString() + "]</a>"

Response.Write("    " + ee + "    ")

}

}

string gg = "<a href=ForumPage.aspx?MclassId=" + mClassId + "&NclassId=" + nClassId + "&BrandId=" + brandId + "&ProductId=" +

productId + "&ForumTitleId=" + forumTitleId + "&pageNum=" + (pageNum + 1).ToString() + ">>></a>"

string ff = "<a href=ForumPage.aspx?MclassId=" + mClassId + "&NclassId=" + nClassId + "&BrandId=" + brandId + "&ProductId=" +

productId + "&ForumTitleId=" + forumTitleId + "&pageNum=" + maxPageNum + ">...." + maxPageNum.ToString() + "</a>"

Response.Write("    " + gg + "    " + ff + "    ")

}

else if (pageNum == maxPageNum)

{

string ff = "<a href=ForumPage.aspx?MclassId=" + mClassId + "&NclassId=" + nClassId + "&BrandId=" + brandId + "&ProductId=" +

productId + "&ForumTitleId=" + forumTitleId + "&pageNum=1>1....</a>"

string gg = "<a href=ForumPage.aspx?MclassId=" + mClassId + "&NclassId=" + nClassId + "&BrandId=" + brandId + "&ProductId=" +

productId + "&ForumTitleId=" + forumTitleId + "&pageNum=" + (pageNum - 1).ToString() + "><<</a>"

Response.Write("    " + ff + "    " + gg + "    ")

for (int j = maxPageNum - 9j <= maxPageNumj++)

{

if (j == pageNum)

{

Response.Write("    <font color = red>[" + j.ToString() + "]</font>     ")

}

else

{

string ee = "<a href=ForumPage.aspx?MclassId=" + mClassId + "&NclassId=" + nClassId + "&BrandId=" + brandId

+ "&ProductId=" + productId + "&ForumTitleId=" + forumTitleId + "&pageNum=" + j.ToString() + ">[" + j.ToString() + "]</a>"

Response.Write("    " + ee + "    ")

}

}

}

else

{

string ff = "<a href=ForumPage.aspx?MclassId=" + mClassId + "&NclassId=" + nClassId + "&BrandId=" + brandId + "&ProductId=" +

productId + "&ForumTitleId=" + forumTitleId + "&pageNum=1>1....</a>"

string gg = "<a href=ForumPage.aspx?MclassId=" + mClassId + "&NclassId=" + nClassId + "&BrandId=" + brandId + "&ProductId=" +

productId + "&ForumTitleId=" + forumTitleId + "&pageNum=" + (pageNum - 1).ToString() + "><<</a>"

Response.Write("    " + ff + "    " + gg + "    ")

if (pageNum - 1 >5 &&maxPageNum - pageNum >5)

{

for (int j = pageNum - 4j <= pageNum + 6j++)

{

if (j == pageNum)

{

Response.Write("    <font color = red>[" + j.ToString() + "]</font>     ")

}

else

{

string ee = "<a href=ForumPage.aspx?MclassId=" + mClassId + "&NclassId=" + nClassId + "&BrandId=" + brandId

+ "&ProductId=" + productId + "&ForumTitleId=" + forumTitleId + "&pageNum=" + j.ToString() + ">[" + j.ToString() + "]</a>"

Response.Write("    " + ee + "    ")

}

}

}

else if (pageNum - 1 <= 5)

{

for (int j = 1j <= 10j++)

{

if (j == pageNum)

{

Response.Write("    <font color = red>[" + j.ToString() + "]</font>    ")

}

else

{

string ee = "<a href=ForumPage.aspx?MclassId=" + mClassId + "&NclassId=" + nClassId + "&BrandId=" +

brandId + "&ProductId=" + productId + "&ForumTitleId=" + forumTitleId + "&pageNum=" + j.ToString() + ">[" +

j.ToString() + "]</a>"

Response.Write("    " + ee + "    ")

}

}

}

else

{

for (int j = maxPageNum - 10j <= maxPageNumj++)

{

if (j == pageNum)

{

Response.Write("    <font color = red>[" + j.ToString() + "]</font>    ")

}

else

{

string ee = "<a href=ForumPage.aspx?MclassId=" + mClassId + "&NclassId=" + nClassId + "&BrandId=" +

brandId + "&ProductId=" + productId + "&ForumTitleId=" + forumTitleId + "&pageNum=" + j.ToString() + ">[" + j.ToString() + "]</a>"

Response.Write("    " + ee + "    ")

}

}

}

string hh = "<a href=ForumPage.aspx?MclassId=" + mClassId + "&NclassId=" + nClassId + "&BrandId=" + brandId + "&ProductId=" +

productId + "&ForumTitleId=" + forumTitleId + "&pageNum=" + (pageNum + 1).ToString() + ">>></a>"

string rr = "<a href=ForumPage.aspx?MclassId=" + mClassId + "&NclassId=" + nClassId + "&BrandId=" + brandId + "&ProductId=" +

productId + "&ForumTitleId=" + forumTitleId + "&pageNum=" + maxPageNum + ">...." + maxPageNum.ToString() + "</a>"

Response.Write("    " + hh + "    " + rr + "    ")

}

}

//************************************************************************************************************

//输出页数并且都加上链接而且页数多的话,显示部分(花线内)

%>

hi./ryw12403/blog/item/a67b963e45de843a71cf6c2f运行结果图,用的是TC。VC 的话要做些修改.while((page[i++]=getche())!='\r')include stdio.hdefine N 40int printend(){char page[5],iprintf(\n\nESC-exit n-nextpage l-lastpage e-endpage s-startpage jumppage :) i=0while((page[i++]=getche())!='\r')page[i]='\0'if(isdigit(page[0])) return atoi(page)else return page[0]}main(){int a,i,kfor(i=1i=Ni++){printf(\n%2d**********************,i)if(i%10==0){ a=printend() k=i switch(a){case 'p':case 'P':if(i10) i-=20 else i=0 break case 'n': case 'N': if(i=N) i=N-10 break case 's': case 'S': i=0break case 'e': case 'E': i=N-10 breakcase 27: exit(0) default:i=a*10-10 if(iN){printf(\nError ,max page is %d.,N/10) printf(Press anykey to continue.) getch() i=N-10 }break }clrscr() }} getchar() }


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/6762545.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-03-27
下一篇 2023-03-27

发表评论

登录后才能评论

评论列表(0条)

保存