分页公共方法-创新互联

public static string GetListPagerInfo(int totalPageCount, int pageIndex, string link)
       {
           if (totalPageCount < 2)
           {
               return string.Empty;
           }分页公共方法

           StringBuilder temp = new StringBuilder(128);

专注于为中小企业提供网站设计制作、网站设计服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业阳新免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了千余家企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。

           if (totalPageCount > 1 && pageIndex > 1)
           {
               temp.AppendFormat(@" 首页", string.Format(link, 1));
           }

           if (pageIndex > 1 && totalPageCount > 0)
           {
               temp.AppendFormat(@" 上一页", string.Format(link, pageIndex - 1));
           }

           int pageNumber = totalPageCount - pageIndex > 5 ? Math.Max(pageIndex - 5, 1) : Math.Max(pageIndex - (9 - (totalPageCount - pageIndex)), 1);
           int count = Math.Min(pageIndex + (9 - (pageIndex - pageNumber)), totalPageCount);

           while (pageNumber <= pageIndex)
           {
               if (pageNumber == pageIndex)
               {
                   temp.AppendFormat(@" {0}", pageNumber);
               }
               else
               {
                   temp.AppendFormat(@" {1}", string.Format(link, pageNumber), pageNumber);
               }
               ++pageNumber;
           }

           while (pageNumber <= count)
           {
               if (pageNumber == pageIndex)
               {
                   temp.AppendFormat(@" {0}", pageNumber);
               }
               else
               {
                   temp.AppendFormat(@" {1}", string.Format(link, pageNumber), pageNumber);
               }
               ++pageNumber;
           }

           if (pageIndex > 0 && pageIndex < totalPageCount)
           {
               temp.AppendFormat(@" 下一页", string.Format(link, pageIndex + 1));
           }

           if (totalPageCount > 1 && pageIndex < totalPageCount)
           {
               temp.AppendFormat(@" 尾页", string.Format(link, totalPageCount));
           }
           return temp.ToString();
       }

 List list = _userService.GetUserList();
           userModel.CurrentPage = RequestQueryString("CurrentPage", 1);
           userModel.PageSize = 1;
           int pageAll = list.Count % userModel.PageSize == 0 ? list.Count / userModel.PageSize : list.Count / userModel.PageSize + 1;
           var listPage=list.Skip(userModel.PageSize * (userModel.CurrentPage - 1)).Take(userModel.PageSize).ToList();
           ViewBag.list = listPage;
           ViewBag.pageStr = Comment.GetListPagerInfo(pageAll, Convert.ToInt32(userModel.CurrentPage), "javascript:searchUserQuestionPageInfo({0})"); ;
           return View("~/Views/Management/User/UserList.cshtml");


分享文章:分页公共方法-创新互联
网址分享:http://bzwzjz.com/article/spjej.html

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 高端网站设计推广 企业网站设计 高端网站设计 成都网站建设 成都网站建设 成都网站建设推广 网站制作公司 LED网站设计方案 网站设计公司 成都网站建设 网站设计 网站设计制作 网站制作 网站建设改版 品牌网站建设 成都网站设计 成都网站建设公司 成都网站建设 四川成都网站设计 网站设计 成都网站设计制作公司 专业网站设计