• 分页webform winform


         #region +AJAX获得功能页码条
    /// <summary>
    /// AJAX获得功能页码条
    /// </summary>
    /// <param name="funName">js方法名</param>
    /// <param name="allrecord">全部记录条数</param>
    /// <param name="allpage">全部页面数</param>
    /// <param name="curpage">当前页码</param>
    /// <param name="groupsize">页码组大小</param>
    /// <param name="pagesize">页容量</param>
    public static string GetPageTxtAjax(string funName, int allrecord, int allpage, int curpage, int groupsize, int pagesize)
    {
    int curGroupPage = 0;
    StringBuilder test = new StringBuilder();
    StringBuilder test2 = new StringBuilder();
    StringBuilder pagetxt = new StringBuilder();
    if (curpage.Equals("") || curpage < 1) curpage = 1;
    if (allrecord.Equals("") || allrecord < 1) allrecord = 1;
    if (pagesize.Equals("") || pagesize < 1) pagesize = 1;
    if (allrecord == 0) { pagetxt.Append("页码:0/0 │ 共0条</TD> <td align='left'> 首页 << 上一页 | 1 Next | >> 尾页 &nbsp;&nbsp;</td></tr></table>"); }
    else
    {
    test2.Append(allpage.ToString());

    if (allpage.Equals("") || allpage < 1) allpage = 1;
    pagetxt.Append("页码:" + curpage.ToString() + "/" + allpage.ToString() + " │ 共" + allrecord.ToString() + "");
    pagetxt.Append("<A href='javascript:" + funName+"(1)' title='首页'>1</A>&nbsp;");
    curGroupPage = (((curpage - 1) / groupsize) * groupsize) + 1;

    if (curGroupPage <= 1) pagetxt.Append("<a href='javascript:" + funName + "(" + curGroupPage + ")' title='回到首页'>&lt;&lt;</A>&nbsp;");
    else pagetxt.Append("<a href='javascript:" + funName + "(" + (curGroupPage - 1) + ")' title='前 " + groupsize + " 页'>&lt;&lt;</A>&nbsp;");

    if (curpage <= 1) pagetxt.Append("<A href='javascript:" + funName + "(" + curpage + ")' title='首页'>Prev</A>&nbsp;");
    else pagetxt.Append("<A href='javascript:" + funName + "(" + (curpage - 1) + ")' title='前一页'>Prev</A>&nbsp;");

    int tempI = 0;
    tempI = curGroupPage;
    do
    {
    if (tempI == curpage) pagetxt.Append("<span class='nowpage'>" + tempI + "</span>&nbsp;");
    else pagetxt.Append("<A href='javascript:" + funName + "(" + tempI + ")'>" + tempI + "</A>&nbsp;");
    tempI = tempI + 1;
    } while (tempI < curGroupPage + groupsize && tempI <= allpage);

    if (curpage < allpage) pagetxt.Append("<A href='javascript:" + funName + "(" + (curpage + 1) + ")' title='后一页'>Next</A>&nbsp;");
    else pagetxt.Append("<A href='javascript:" + funName + "(" + curpage + ")' title='后一页'>Next</A>&nbsp;");

    if (curGroupPage + groupsize > allpage) pagetxt.Append("<a href='javascript:" + funName + "(" + allpage + ")' title='后 " + groupsize + " 页'>&gt;&gt;</A>&nbsp;");
    else pagetxt.Append("<a href='javascript:" + funName + "(" + (curGroupPage + groupsize) + ")' title='后" + groupsize + "页'>&gt;&gt;</A>&nbsp;");

    pagetxt.Append("<A href='javascript:" + funName + "(" + allpage + ")' title='最后一页'>" + allpage + "</A>");
    }
    test.Append("allpage=" + allpage + ",allrecord=" + allrecord + ",pagesize=" + pagesize + ",groupsize=" + groupsize + ",curGroupPage=" + curGroupPage + ",curpage=" + curpage);
    return pagetxt.ToString();
    }
    #endregion
    #region +WEBFORM获得功能页码条
    /// <summary>
    /// WEBFORM获得功能页码条
    /// </summary>
    /// <param name="url">页码连接地址</param>
    /// <param name="searcheurl">搜索url</param>
    /// <param name="allrecord">全部记录条数</param>
    /// <param name="allpage">全部页面数</param>
    /// <param name="curpage">当前页码</param>
    /// <param name="groupsize">页码组大小</param>
    /// <param name="pagesize">页容量</param>
    public static string GetPageTxt(string url, string searcheurl, int allrecord, int allpage, int curpage, int groupsize, int pagesize)
    {
    int curGroupPage = 0;
    StringBuilder test = new StringBuilder();
    StringBuilder test2 = new StringBuilder();
    StringBuilder pagetxt = new StringBuilder();
    if (curpage.Equals("") || curpage < 1) curpage = 1;
    if (allrecord.Equals("") || allrecord < 1) allrecord = 1;
    if (pagesize.Equals("") || pagesize < 1) pagesize = 1;
    if (allrecord == 0) { pagetxt.Append("页码:0/0 │ 共0条</TD> <td align='left'> 首页 << 上一页 | 1 Next | >> 尾页 &nbsp;&nbsp;</td></tr></table>"); }
    else
    {
    test2.Append(allpage.ToString());

    if (allpage.Equals("") || allpage < 1) allpage = 1;
    pagetxt.Append("页码:" + curpage.ToString() + "/" + allpage.ToString() + " │ 共" + allrecord.ToString() + "");
    pagetxt.Append("<A href='" + url + "1' title='首页'>1</A>&nbsp;");
    curGroupPage = (((curpage - 1) / groupsize) * groupsize) + 1;

    if (curGroupPage <= 1) pagetxt.Append("<a href='" + url + curGroupPage + searcheurl + "' title='回到首页'>&lt;&lt;</A>&nbsp;");
    else pagetxt.Append("<a href='" + url + (curGroupPage - 1) + searcheurl + "' title='前 " + groupsize + " 页'>&lt;&lt;</A>&nbsp;");

    if (curpage <= 1) pagetxt.Append("<A href='" + url + curpage + searcheurl + "' title='首页'>Prev</A>&nbsp;");
    else pagetxt.Append("<A href='" + url + (curpage - 1) + searcheurl + "' title='前一页'>Prev</A>&nbsp;");

    int tempI = 0;
    tempI = curGroupPage;
    do
    {
    if (tempI == curpage) pagetxt.Append("<span class='nowpage'>" + tempI + "</span>&nbsp;");
    else pagetxt.Append("<A href='" + url + tempI + searcheurl + "'>" + tempI + "</A>&nbsp;");
    tempI = tempI + 1;
    } while (tempI < curGroupPage + groupsize && tempI <= allpage);

    if (curpage < allpage) pagetxt.Append("<A href='" + url + (curpage + 1) + searcheurl + "' title='后一页'>Next</A>&nbsp;");
    else pagetxt.Append("<A href='" + url + curpage + searcheurl + "' title='后一页'>Next</A>&nbsp;");

    if (curGroupPage + groupsize > allpage) pagetxt.Append("<a href='" + url + allpage + searcheurl + "' title='后 " + groupsize + " 页'>&gt;&gt;</A>&nbsp;");
    else pagetxt.Append("<a href='" + url + (curGroupPage + groupsize) + searcheurl + "' title='后" + groupsize + "页'>&gt;&gt;</A>&nbsp;");

    pagetxt.Append("<A href='" + url + allpage + searcheurl + "' title='最后一页'>" + allpage + "</A>");
    }
    test.Append("allpage=" + allpage + ",allrecord=" + allrecord + ",pagesize=" + pagesize + ",groupsize=" + groupsize + ",curGroupPage=" + curGroupPage + ",curpage=" + curpage);
    return pagetxt.ToString();
    }
  • 相关阅读:
    hdu1257
    P6198 [EER1]单调栈 题解(分治+构造)
    P3193 [HNOI2008]GT考试 题解(kmp+矩阵快速幂)
    Product of GCDs 题解(欧拉降幂+贡献)
    P2501 [HAOI2006]数字序列 题解(dp+构造)
    欧拉降幂
    I love max and multiply 题解(二进制dp)
    永不言弃 题解(线段树维护hash+二分)
    Problem D. Ice Cream Tower 题解(二分+贪心)
    E. Kefa and Watch 题解(线段树维护hash+循环节结论)
  • 原文地址:https://www.cnblogs.com/gylspx/p/bdfs.html
Copyright © 2020-2023  润新知