MVC三种分页方法

2021-01-29 21:16

阅读:431

标签:parameter   tor   param   分页   data   options   models   ica   page   

View部分:

@using WebApplication1.Models;分页方法1引包
@*@using PagedList.Mvc;
@using WebApplication1.Models;
@model PagedList.IPagedList*@

 

@*分页方法1*@
@Html.Pager(Model, new PagerOptions
{
Id = "htmlPager",
PageIndexParameterName = "pageIndex",
FirstPageText = "首页",
PrevPageText = "上一页",
NextPageText = "下一页",
LastPageText = "尾页",
CssClass = "pagination pagination-sm",
CurrentPagerItemTemplate = "

  • " +
    "{0}
  • ",
    DisabledPagerItemTemplate = "
  • {0}
  • ",
    PagerItemTemplate = "
  • {0}
  • "
    })
    @*分页方法2*@
    @*@Html.PagedListPager(Model, page => Url.Action("UserList", new { page }))*@

    Controller部分:

    //第三方插件分页1:using Webdiyer.WebControls.Mvc;
    public ActionResult UserList(int pageIndex = 1)
    {
    List userListAll = education.t_users.ToList();
    userListAll = userListAll.ToPagedList(pageIndex, 5);
    return View(userListAll);
    }

    //第三方插件分页2:using PagedList;
    //public ActionResult UserList(int page = 1)
    //{
    // List userListAll = education.t_users.ToList();
    // return View(userListAll.ToPagedList(page, 5));
    //}
    //用户详情
    public ActionResult DetailsUser(int id)
    {
    var users = education.t_users.Where(u => u.data_state == 0 && u.us_sid == id).FirstOrDefault();
    return View(users);
    }

    MVC三种分页方法

    标签:parameter   tor   param   分页   data   options   models   ica   page   

    原文地址:https://www.cnblogs.com/ypyp123/p/13199473.html


    评论


    亲,登录后才可以留言!