zoukankan      html  css  js  c++  java
  • 实现 Repeater 控件和 DataList 控件的分页,看到先留下

    实现 Repeater 控件和 DataList 控件的分页 !!!

     
     

    源文件:(还需要自己添加上 Repeater(id=rptList) 控件 !)

     <div style="padding: 5px; padding-left:10px; background-color: #dedede; 88%">
            <asp:Label ID="lblPages" runat="server" Text="Label" ForeColor="#444444"></asp:Label>&nbsp;&nbsp;
            <asp:Label ID="lblCurrentPage" runat="server" ForeColor="#444444"></asp:Label>
            &nbsp; &nbsp;<asp:HyperLink ID="lnkPrev" runat="server">上一页</asp:HyperLink>
            <asp:HyperLink ID="lnkNext" runat="server">下一页</asp:HyperLink>
            &nbsp;
        </div>

    =================================================================================================

    .CS 文件:

    //实现 Repeater 分页 !!!
        private void SelectNewsListBySortID(int sortID)
        {
            PagedDataSource pds = new PagedDataSource();
            DataTable dt = CatalogAccess.SelectNewsListBySortID(sortID);
            pds.DataSource = dt.DefaultView;
            pds.AllowPaging = true;
            pds.PageSize = 3;

            int curPage;
            if (Request.QueryString["Page"] != null)
            {
                curPage = Convert.ToInt32(Request.QueryString["Page"]);
            }
            else
            {
                curPage = 1;
            }
            pds.CurrentPageIndex = curPage - 1;
            lblPages.Text = " 共 " + Convert.ToString(pds.PageCount) + " 页 ";
            lblCurrentPage.Text = "当前第 " + curPage.ToString() + " 页 ";

            if (pds.PageCount == 1)
            {
                this.lnkPrev.Visible = false;
                this.lnkNext.Visible = false;
            }
            else
            {
                if (!pds.IsFirstPage)
                {
                    if (pds.IsLastPage)
                    {
                        lnkNext.Visible = false;
                    }
                    lnkPrev.Visible = true;
                    lnkPrev.NavigateUrl = Request.CurrentExecutionFilePath + "?SortID=1&id=" + id +

    "&DetailsID=0&Page=" + Convert.ToString(curPage - 1);  //棕色字体根据实际情况修改
                }
                if (!pds.IsLastPage)
                {
                    if (pds.IsFirstPage)
                    {
                        lnkPrev.Visible = false;
                    }
                    lnkNext.Visible = true;
                    lnkNext.NavigateUrl = Request.CurrentExecutionFilePath + "?SortID=1&id=" + id +

    "&DetailsID=0&Page=" + Convert.ToString(curPage + 1);
                }
            }

            rptList.DataSource = pds;
            rptList.DataBind();
        }

  • 相关阅读:
    c#中跨线程调用windows窗体控件
    像职业选手样编码:地道Python
    数据挖掘笔记 第一章:引言
    SVN使用教程(基于SAE)
    常用的js函数
    linux服务之tuned
    PHP 开启短标签
    如叶梦想!
    分布式控制系统Git学习
    LabVIEW(十六):多列列表框控件
  • 原文地址:https://www.cnblogs.com/juexin/p/2861500.html
Copyright © 2011-2022 走看看