当前位置:编程学习 > asp >>

这两天自己模仿写的一个Asp.Net的显示分页方法 附加实体转换和存储过程

之前自己一直用Aspnetpager控件来显示项目中的分页,但是每次都要拖一个aspnetpager的控件进去,感觉很不舒服,因为现在自己写的webform都不用服务器控件了,所以自己仿照aspnetpager写了一个精简实用的返回分页显示的html方法,其他话不说了,直接上代码。
 
分页显示信息的实体类:
  View Code
public class Pager
    {
        private string _firstPageText;
        /// <summary>
        /// 最前一页文字显示 默认显示为"首页"
        /// </summary>
        public string FirstPageText
        {
            get {
                return string.IsNullOrEmpty(_firstPageText)? "首页" : _firstPageText;
            }
            set {
                _firstPageText = value;
            }
        }

        private string _prePageText;
        /// <summary>
        /// 上一页文字显示 默认显示为"上一页"
        /// </summary>
        public string PrePageText
        {
            get
            {
                return string.IsNullOrEmpty(_prePageText) ? "上一页" : _prePageText;
            }
            set
            {
                _prePageText = value;
            }
        }

        private string _nextPageText;
        /// <summary>
        /// 下一页文字显示 默认显示为"下一页"
        /// </summary>
        public string NextPageText
        {
            get
            {
                return string.IsNullOrEmpty(_nextPageText) ? "下一页" : _nextPageText;
            }
            set
            {
                _nextPageText = value;
            }
        }

        private string _lastPageText;
        /// <summary>
        /// 末页文字显示 默认显示为"末页"
        /// </summary>
        public string LastPageText
        {
            get
            {
                return string.IsNullOrEmpty(_lastPageText) ? "末页" : _lastPageText;
            }
            set
            {
                _lastPageText = value;
            }
        }

        /// <summary>
        /// 总记录数
        /// </summary>
        public int RecordCount { get; set; }

        private int _pagesize=15;
        /// <summary>
        /// 每页分页尺寸 默认为15
        /// </summary>
        public int PageSize {
            get {
                return _pagesize == 0 ? 15 : _pagesize;
            }set{
                _pagesize = value;
            }
        }

        private int _pageIndex=1;
        /// <summary>
        /// 当前页码
        /// </summary>
        public int PageIndex {
            get {
                return _pageIndex == 0 ? 1 : _pageIndex;
            }
            set {
                _pageIndex = value;
            }
        }

        private int _maxShowPageSize = 10;
        /// <summary>
        /// 显示页码列表的最大个数 默认为10
        /// </summary>
        public int MaxShowPageSize {
            get {
                return _maxShowPageSize;
           

补充:Web开发 , ASP.Net ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,