• Cnic.CodeBase.PagingHelper.BuildLinks


            public static string ConcatAnchor(string url, string attr, string queryName, string pageNum, string innerText)
    {
    string[] rtun=new string[10];
    rtun[0]=("<a ");
    rtun[1] = (attr);
    rtun[2] = (" href=\"");
    rtun[3] = (url);
    rtun[4] = (queryName);
    rtun[5] = ("=");
    rtun[6] = (pageNum);
    rtun[7] = ("\">");
    rtun[8] = (innerText);
    rtun[9] = ("</a>\n");
    return String.Concat(rtun);
    }


    /// <summary>
            /// 数字分页
            /// </summary>
            /// <param name="Url">Url链接,此参数要求链接的最后一位字符为&或?</param>
            /// <param name="QueryName">页码参数名称</param>
            /// <param name="PageNum">当前页码,从1开始</param>
            /// <param name="PageTotal">总页数</param>
            /// <param name="LinkSize">显示链接的个数</param>
            /// <param name="DivAttr">Div的属性,可以指定id,此参数可以为为空</param>
            /// <param name="SpanAttr">Span的属性,可以指定id,此参数可以为为空</param>
            /// <param name="AAttr">链接的属性,不可以指定id,此参数可以为为空</param>
            public static string BuildLinks(string Url, string QueryName, int PageNum, int PageTotal, int LinkSize, string DivAttr,string SpanAttr, string AAttr)
    {
    StringBuilder rtun = new StringBuilder();
    rtun.Append("<div ");
    rtun.Append(DivAttr);
    rtun.Append(" >\n");
    int pageNum = PageNum > 0 ? PageNum : 1;
    int pageCount = PageTotal > 0 ? PageTotal : 1;
    if (pageNum > pageCount) { pageNum = pageCount; }
    int linkNum = LinkSize > 0 ? LinkSize : 1;
    int pageStart = ((pageNum - 1) / linkNum) * linkNum + 1;
    int pageEnd = pageStart + linkNum;
    pageEnd = pageEnd > pageCount ? pageCount + 1 : pageEnd;

    rtun.Append(ConcatAnchor(Url, AAttr, QueryName, "1", "首页"));
    if (pageNum > 1)
    {
    rtun.Append(ConcatAnchor(Url, AAttr, QueryName, ((int)(pageNum - 1)).ToString(), "上一页"));
    }
    for (int i = pageStart; i < pageEnd; i++)
    {
    if (i == pageNum)
    {
    rtun.Append("<span "+SpanAttr+" >");
    rtun.Append(i.ToString());
    rtun.Append("</span>\n");
    }
    else
    {
    rtun.Append(ConcatAnchor(Url, AAttr, QueryName, i.ToString(), i.ToString()));
    }
    }
    if (pageNum < pageCount)
    {
    rtun.Append(ConcatAnchor(Url, AAttr, QueryName, ((int)(pageNum+1)).ToString(), "下一页"));
    }
    rtun.Append(ConcatAnchor(Url, AAttr, QueryName, pageCount.ToString(), "末页"));
    rtun.Append("</div>");
    return rtun.ToString();
    }


    /*
    * LZ:
    * BuildLinks("/Ajax.aspx?Action=LoadList&","Page",i,33,10,"id=\"Cnic_Page_Tool\" class=\"PageBar\"","",null)
    *
    */
    
    





  • 相关阅读:
    代码中引用res里的颜色、图片
    time.setToNow() 取当前时间,月份有误
    adb报错:The connection to adb is down, and a severe&nbs
    安卓下拉刷新、上拉加载数据显示
    4、安卓数据存储——sqlite
    3、安卓数据存储——缓存、内存管理
    2、安卓数据存储——本地文件
    1、安卓数据存储机制——sharedPreference
    一个异步任务接收两个url下载两个图片
    adb报错:The connection to adb is down, and a severe&nbs
  • 原文地址:https://www.cnblogs.com/CodeBase/p/2230202.html
Copyright © 2020-2023  润新知