简单效果图:(框架:MVC+NHibernate)

ASP.NET MVC 之表格分页

要点:

(1)首先建立表格分页Model(GridModel.cs)

(2)然后建立数据展示页(PageCloth.cshtml)

(3)再建分页版页(_Pager.cshtml)

(4)建立分页链接功能(_SmartLink.cshtml)

(5)调用分页功能(HomeController.cs)

详细步骤:

 1、建立表格分页Model(GridModel.cs)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Entity;
using System.Runtime.Serialization;

namespace BLUS.Models
{   
    public class GridModel
    {
        /// <summary>
        /// 总记录数
        /// </summary>
       
        public int TotalRecordCount { set; get; }
        /// <summary>
        /// 页大小-每页显示几条记录
        /// </summary>
        
        public int PageSiae { set; get; }
        /// <summary>
        /// 当前第几页
        /// </summary>
     
        public int CurrentPageIndex { set; get; }
        /// <summary>
        /// 总页数
        /// </summary>

        public int PageCount
        {
            get
            {
                return TotalRecordCount % PageSiae == 0 ? TotalRecordCount / PageSiae : TotalRecordCount / PageSiae + 1;
            }
        }
        /// <summary>
        /// 默认分页,页大小5,当前第一页
        /// </summary>
    
        public GridModel()
        {
            this.PageSiae = 5;
            this.CurrentPageIndex = 1;
        }
     
        public IList<Cloth> Clothes
        {
            get;
            set;
        }
    }
}
View Code

相关文章:

  • 2021-08-07
  • 2021-11-07
  • 2021-06-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-28
  • 2021-09-15
  • 2022-02-05
  • 2021-11-20
  • 2022-12-23
  • 2021-07-24
  • 2021-08-06
相关资源
相似解决方案