• MVC Page分页控件


    MVCPage帮助类

    控制器代码

    public ActionResult Article(int? page)
            {
                //Session["ArticleClass"] = context.ArticleClass.ToList();
                PagerInfo info = new PagerInfo();
                info.RecordCount = context.Article.ToList().Count();//条目总数
                info.PageSize = 10;//每页条目数
                info.CurrentPageIndex = (page != null ? (int)page : 1);//当前页
                List<Article> list = context.Article.OrderBy(a => a.Id).Skip((info.CurrentPageIndex - 1) * info.PageSize).Take(info.PageSize).ToList();
                PagerQuery<PagerInfo, IEnumerable<Article>> data = new PagerQuery<PagerInfo, IEnumerable<Article>>(info, list);
                return View(data);
            }

    前台页面代码

    需要先对PageQuery集合的引用
    <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<PagerQuery<PagerInfo,IEnumerable<PostCounterManage.Models.Article>>>" %>
    
    foreach (var item in Model.EntityList)
    
    <%= Html.Pager("pager", Model.Pager.CurrentPageIndex, Model.Pager.PageSize, Model.Pager.RecordCount,"pages", PageMode.Numeric)%>

    原文地址:http://www.cnblogs.com/JackFeng/archive/2010/01/25/JackFeng.html

  • 相关阅读:
    linux系统scp和rsync同步命令介绍
    linux系统发现系统变慢
    linux系统centos6和centos7开机流程及定时任务语法
    elasticsearch for windows
    elasticsearch for linux
    Python操作elasticsearch
    elasticsearch之快速上手
    elasticsearch简介
    flask中使用celery
    GoJS
  • 原文地址:https://www.cnblogs.com/a849788087/p/6182276.html
Copyright © 2020-2023  润新知