zoukankan      html  css  js  c++  java
  • 上两篇文章中分页的使用方法

    1.编写类方法

     1public abstract class ProcMethod
     2    {
     3        private ProcMethod()
     4        {
     5            //
     6            // TODO: 在此处添加构造函数逻辑
     7            //
     8        }

     9
    10        /// <summary>
    11        /// Get Record List.
    12        /// </summary>
    13        /// <param name="selectstr">fields that need to be selected.</param>
    14        /// <param name="tbname">table name</param>
    15        /// <param name="querystr">select condition</param>
    16        /// <param name="key">key used to sort.</param>
    17        /// <param name="ordertype">index direction 1 down - 0 up</param>
    18        /// <param name="pageSize">page size</param>
    19        /// <param name="pageNumber">page number</param>
    20        /// <param name="rscount">out put, total records.</param>
    21        /// <param name="pagecount">out put,total pages due to current pagesize.</param>
    22        /// <returns></returns>

    23        public static DataTable Get(SqlServer sql,string selectstr, string tbname, string querystr, string key, int ordertype, int pageSize, ref int pageNumber, out int rscount, out int pagecount)
    24        {
    25            SqlParameter[] sp = new SqlParameter[]{
    26                new SqlParameter("@selectstr",selectstr),
    27                new SqlParameter("@tbname",tbname),
    28                new SqlParameter("@querystr",querystr),
    29                new SqlParameter("@pkey",key),
    30                new SqlParameter("@ordertype",ordertype),
    31                new SqlParameter("@pagesize",pageSize),
    32                new SqlParameter("@page",pageNumber),
    33                new SqlParameter("@rscount",0),
    34                new SqlParameter("@pagecount",0)
    35            }
    ;
    36            sp[6].Direction = ParameterDirection.InputOutput;
    37            sp[7].Direction = ParameterDirection.Output;
    38            sp[8].Direction = ParameterDirection.Output;
    39            DataTable dt = null;
    40
    41            DataSet ds = sql.GetDataSet("page_proc", sp);
    42            if (ds != null) dt = ds.Tables[0];
    43            
    44            pageNumber = Convert.ToInt32(sp[6].Value);
    45            rscount = Convert.ToInt32(sp[7].Value);
    46            pagecount = Convert.ToInt32(sp[8].Value);
    47            return dt;
    48        }

    49    }

    2.调用方法:

     1 public int _pageSize = 24;
     2    public int _currentPage = 0;
     3    public int _rsCount = 0;
     4    public int _PageCount = 0;
     5
     6    protected void Page_Load(object sender, EventArgs e)
     7    {
     8        GetList();
     9    }

    10
    11    public void GetList()
    12    {
    13        string constr = NT.Config.SystemInfo.Config.ConnString;
    14        using (NT.Data.SqlServer.SqlServer sqlserver = new NT.Data.SqlServer.SqlServer(constr))
    15        {
    16            DataTable dt = NT.Data.SqlServer.ProcMethod.Get(sqlserver, """cms_article""articletitle  like '%潮团%'  ""articleid"1, _pageSize, ref _currentPage, out _rsCount, out _PageCount);
    17
    18            if (dt != null)
    19            {
    20                rpterNewsList.DataSource = dt.DefaultView;
    21                rpterNewsList.DataBind();
    22            }

    23            listInfoLabel.Text = "全部共" + _rsCount + "篇,每页" + _pageSize + "篇,当前第" + _currentPage + "/" + _PageCount + "";
    24            pageInfoLiteral.Text = NT.Web.Pagination.Show(_currentPage, _PageCount, 10"?page=""");
    25        }

    26    }

    3.显示结果:

  • 相关阅读:
    css3记事
    ele
    vue记事1
    HBuilder
    继承与面向对象设计
    实现
    设计与声明
    资源管理
    构造/析构/赋值运算
    让自己习惯C++
  • 原文地址:https://www.cnblogs.com/cancer_xu/p/1607142.html
Copyright © 2011-2022 走看看