• 完美的ASP.NET页面分页控件


    一,引入控件(AspNetPager.dll)

    二,写方法

    /// <summary>
        /// 完美的ASP.NET页面分页控件
        /// </summary>
        /// <param name="PageSize">每页显示的条数</param>
        /// <param name="PageIndex">当前页</param>
        /// <param name="DoCount">是否显示总条数</param>
        /// <param name="RowCount">总条数</param>
        /// <param name="TableName">要显示的数据表名</param>
        /// <param name="PID">数据表的主键</param>
        /// <param name="ColList">显示的字段名</param>
        /// <param name="Condition">条件,主要是WHERE</param>
        /// <param name="OrderBy">排序</param>
        /// <returns>DataSet数据集</returns>   

    public DataSet DoPageList(int PageSize, int PageIndex, bool DoCount, out int RowCount,
    string TableName, string PID, string ColList, string Condition, string OrderBy)
        {

            if (ColList == "" || ColList == null) ColList = "*";
            if (Condition == null || Condition == "") Condition = "";
            if (OrderBy == null || OrderBy == "") OrderBy = "";
            string strSQL = "select * from (select ROWNUM R,A.* from ( select " + ColList + " " + " from " + TableName + " " + Condition + " " + OrderBy + ") A) where R > " + (PageIndex - 1) * PageSize + " and R <=" + PageIndex * PageSize;
            if (DoCount)
            {
                string sqlcount = "select count(1) from " + TableName + " " + Condition + " " + OrderBy;
                object obj = DbFactory.Instance.GetDbHelp().ExecuteScalar(sqlcount);
                if (obj != null)
                {
                    RowCount = int.Parse(obj.ToString());
                }
                else
                {
                    RowCount = 0;
                }
            }
            else
            {
                RowCount = 0;
            }
            return DbFactory.Instance.GetDbHelp().GetDataSet(strSQL);

        }

    三.引用方法

         int RowCount = 0;
            DataSet ds = new DataSet();
            ds = DoPageList(this.AspNetPager1.PageSize, this.AspNetPager1.CurrentPageIndex, true, out RowCount, "codes", "", "", "", "");
            this.GridView1.DataSource = ds;
            this.GridView1.DataBind();
            AspNetPager1.RecordCount = RowCount;
            AspNetPager1.CustomInfoHTML = "&nbsp;<font color=\"blue\"><b>共有:" + RowCount + "条信息,总页数:" + AspNetPager1.PageCount + ",当前位置:第" + AspNetPager1.CurrentPageIndex + "页</b></font>";
            ds.Dispose();

  • 相关阅读:
    Java基于Socket文件传输示例
    mysql 改变编码
    POI应用:利用word模板批量生成word文档(java中word文档的读写)
    Win 7—FTP服务器配置
    Chrome 快捷键
    JAVA中使用FTPClient上传下载 java利用ftp协议上传文件(by me)
    JAVA中使用FTPClient上传下载
    如何去除TD之间的空隙
    较丰富的教程
    输入年月 返回当月天数.html
  • 原文地址:https://www.cnblogs.com/juan/p/1440607.html
Copyright © 2020-2023  润新知