zoukankan      html  css  js  c++  java
  • 分页算法

     public string RenderToHTML()
            {
                Check();
                StringBuilder sb = new StringBuilder();
                //double tempCount = (TotalCount+(0.0) )/ PageSize;
                
    //int pageCount = (int)Math.Ceiling(tempCount);
                int visibleStart = CurrentPageIndex - MaxPageCount / 2;
                if (visibleStart<1)//6还是没区别
                {
                    visibleStart = 1;
                }
                int visibleEnd = visibleStart + MaxPageCount;
                if (visibleEnd > PageCount)
                {
                    visibleEnd = PageCount;
                }
                if (CurrentPageIndex>1)
                {
                    sb.Append(GetPageLink(1,"首页"));
                    sb.Append(GetPageLink(CurrentPageIndex-1,"上一页"));
                }
                else
                {
                    sb.Append("<span>首页</span>");
                    sb.Append("<span>上一页</span>");
                }
                for (int i = visibleStart; i <=visibleEnd; i++)
                {
                    if (i==CurrentPageIndex)
                    {
                        sb.Append("<span>").Append(i).Append("</span>");
                    }
                    else
                    {
                        sb.Append(GetPageLink(i,i.ToString()));
                    }
                }
                if (CurrentPageIndex < PageCount)
                {
                    sb.Append(GetPageLink(CurrentPageIndex+1,"下一页"));
                    sb.Append(GetPageLink(PageCount, "末页"));
                }
                else
                {
                    sb.Append("<span>下一页</span>");
                    sb.Append("<span>末页</span>");
                }
                return sb.ToString();
            }
  • 相关阅读:
    Shiro认证过程?
    使用过Redis做异步队列么,你是怎么用的?
    使用 Spring Boot有什么好处
    Spring Boot、Spring MVC 和 Spring 有什么区别?
    es
    python并发编程
    Go基础05
    Go04基础
    Go03基础
    Go基础02
  • 原文地址:https://www.cnblogs.com/bober/p/2667649.html
Copyright © 2011-2022 走看看