成都创新互联网站制作重庆分公司

分页公共方法-创新互联

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://cxhlcq.com/article/spjej.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部