我只想问你是否知道asp.net c#中的一些分页代码?
我有很多要查询的数据,我想在下拉列表和页面链接中使用分页。除了使用像gridview这样自动生成分页的asp.net控件之外还有什么方法吗?
请帮忙。感谢
答案 0 :(得分:1)
您可以查看此链接。本教程包含代码和更好的解释。
http://www.codeproject.com/Articles/32559/Paging-in-Grid-View-using-Slider-Extender
快乐的代码!
答案 1 :(得分:0)
我不知道这是否是您所需要的,但在我的项目中,我编写了自己的代码来生成Data Pager。它基于以下5个参数生成参考表:
public static string FormPager(string blink, int page, int tpc, bool first_last, bool prev_next) { string retstr = ""; if (tpc > 1) { retstr = ""; if (first_last) { if(page!=1) retstr = retstr + "First"; else retstr = retstr + "First"; } if (prev_next) { if (page > 1) retstr = retstr + "Previous"; } if (page != 1) retstr = retstr + "1"; else retstr = retstr + "1"; if (tpc "; if (i == page) retstr = retstr + i.ToString(); else { retstr = retstr + "" + i.ToString() + ""; } retstr = retstr + ""; } } else { if (page "; retstr = retstr + "" + i.ToString() + ""; retstr = retstr + ""; } } else { retstr = retstr + "..."; for (int i = 2; i > 0; i--) { retstr = retstr + ""; retstr = retstr + "" + (page - i).ToString() + ""; retstr = retstr + ""; } } if (page != 1) retstr = retstr + "" + page.ToString() + ""; if ((page + 5) >= tpc) { for (int i = page + 1; i "; retstr = retstr + "" + i.ToString() + ""; retstr = retstr + ""; } } else { for (int i = 1; i "; retstr = retstr + "" + (page + i).ToString() + ""; retstr = retstr + ""; } retstr = retstr + "..."; } } if (page != tpc) retstr = retstr + "" + tpc.ToString() + ""; else retstr = retstr + "" + tpc.ToString() + ""; if (prev_next) { if (page Next"; } if (first_last) { if(page!=tpc) retstr = retstr + "Last"; else retstr = retstr + "Last"; } retstr = retstr + ""; } return retstr; }
但是您需要根据Request.QueryString
中的参数手动限制查询答案 2 :(得分:0)
查看这些参考资料。尽管这些文章很老,但它们确实提供了有关自定义分页和排序的绝佳信息。