Pagination
程序员文章站
2022-04-14 19:17:06
using System.Collections.Generic; namespace Oyang.Tool { public interface IPagination { int PageIndex { get; set; } int PageSize { get; set; } int Tot... ......
using system.collections.generic; namespace oyang.tool { public interface ipagination { int pageindex { get; set; } int pagesize { get; set; } int totalcount { get; set; } string sortfield { get; set; } bool isasc { get; set; } } public interface ifullpagination : ipagination { int pagecount { get; } int buttoncount { get; set; } list<int> listpagebutton { get; } list<int> calcpagebutton(); } public class pagination : ipagination { public int pageindex { get; set; } public int pagesize { get; set; } public int totalcount { get; set; } public string sortfield { get; set; } public bool isasc { get; set; } } public class fullpagination : pagination, ifullpagination { public int pagecount { get { return totalcount % pagesize == 0 ? totalcount / pagesize : totalcount / pagesize + 1; } } public int buttoncount { get; set; } = 5; list<int> _listpagebutton = null; public list<int> listpagebutton { get; } public list<int> calcpagebutton() { _listpagebutton = new list<int>(); int temp1 = (buttoncount - 1) / 2; int temp2 = buttoncount - 1 - temp1; int startpageindex = 1; int endpageindex = 1; if (pagecount <= buttoncount) { startpageindex = 1; endpageindex = pagecount; } else if (pageindex <= temp1) { startpageindex = 1; endpageindex = startpageindex + buttoncount - 1; } else if (pageindex + temp2 > pagecount) { endpageindex = pagecount; startpageindex = endpageindex - buttoncount + 1; } else { startpageindex = pageindex - temp1; endpageindex = pageindex + temp2; } for (int i = startpageindex; i <= endpageindex; i++) { _listpagebutton.add(i); } return _listpagebutton; } } }
上一篇: asp获取数据库中表名和字段名的代码
下一篇: ASP文件中的安全问题
推荐阅读