• 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

  • 相关阅读:
    Java杂项
    JFrog Artifactory
    TestNG+Selenium
    Linux杂项
    Java
    Spring Boot
    学习ThinkPHP第一天
    linux下文件解压
    php中require_once与include_once的区别
    ubuntu下的wps office for linux
  • 原文地址:https://www.cnblogs.com/a849788087/p/6182276.html
Copyright © 2020-2023  润新知