码迷,mamicode.com
首页 > Web开发 > 详细

MVC三种分页方法

时间:2020-06-27 20:19:43      阅读:98      评论:0      收藏:0      [点我收藏+]

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

View部分:

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

 

@*分页方法1*@
@Html.Pager(Model, new PagerOptions
{
Id = "htmlPager",
PageIndexParameterName = "pageIndex",
FirstPageText = "首页",
PrevPageText = "上一页",
NextPageText = "下一页",
LastPageText = "尾页",
CssClass = "pagination pagination-sm",
CurrentPagerItemTemplate = "<li class=\"active\">" +
"<a href=\"#\">{0}</a></li>",
DisabledPagerItemTemplate = "<li class=\"active\"><a href=\"#\">{0}</a></li>",
PagerItemTemplate = "<li>{0}</li>"
})
@*分页方法2*@
@*@Html.PagedListPager(Model, page => Url.Action("UserList", new { page }))*@

Controller部分:

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

//第三方插件分页2:using PagedList;
//public ActionResult UserList(int page = 1)
//{
// List<t_users> userListAll = education.t_users.ToList();
// return View(userListAll.ToPagedList(page, 5));
//}
//用户详情
public ActionResult DetailsUser(int id)
{
var users = education.t_users.Where<t_users>(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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!