zoukankan      html  css  js  c++  java
  • .net mvc 分页

    分页类(需要从数据库库得到的只有两个数据,一个要展示的数据列表,还有就是总记录数)

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    
    namespace NewProductImport.Common.Models
    {
        public class ProductListPage
        {
            //后台从数据获取的数据列表(用于在前台表格中展示的数据)
            //SELECT * FROM ...
            public List<Product> product
            {
                get;
                set;
            }
            #region  分页相关
            //每页记录数
            public int PageSize
            {
                get { return _pageSize; }
                set { _pageSize = value; }
            }
            //位pageSize设一个初始值
            private int _pageSize = 2;
            
            //第一次进行查询的时候,页码默认的是1
            public int CurrentPageIndex
            {
                get { return _currentPageIndex; }
                set { _currentPageIndex = value; }
            }
            private int _currentPageIndex = 1;
    
            //总记录数--->需要单独从数据库查
            //SELECT COUNT(*) FROM ...
            public int TotalRecordCount
            {
                get;
                set;
            }
    
            public int pageCount
            {
                get
                {
                    if (TotalRecordCount % PageSize == 0)
                    {
                        return TotalRecordCount / PageSize;
                    }
                    else
                    {
                        return TotalRecordCount / PageSize + 1;
                    }
                }
            }
    
            //是否有上一页(当前页码大于1)
            public bool HasPrew
            {
                get { return CurrentPageIndex > 1; }
            }
    
            //是否有下一页(当前页码小于总页数)
            public bool HasNext
            {
                get { return CurrentPageIndex < pageCount; }
            }
            #endregion
        }   
    }
  • 相关阅读:
    ansible-乱
    linux-PXE-12
    linux-ntp-10
    linux-selinxu---性能 -8
    linux-系统启动流程-7
    linux-网络管理-6
    linux-文件系统-5
    linux-包管理器-4
    linux-shell脚本基础-2
    linux-history-ps1-1
  • 原文地址:https://www.cnblogs.com/mrxiaohe/p/5219744.html
Copyright © 2011-2022 走看看