快上网专注成都网站设计 成都网站制作 成都网站建设
成都网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

分页公共方法-创新互联

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://6mz.cn/article/spjej.html

其他资讯