资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

分页公共方法-创新互联

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://cdkjz.cn/article/spjej.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220