Asp.net Mvc使用PagedList分页
https://github.com/troygoode/PagedList
1. Nuget 安装package
@{ ViewBag.Title = "Processes Listing"; } @using PagedList.Mvc; @using PagedList; <link href="/Content/PagedList.css" rel="stylesheet" type="text/css" /> <h2>List of Processes</h2> <ul> @foreach(var process in ViewBag.Processes){ <li>@process.ProcessName</li> } </ul> @Html.PagedListPager((IPagedList)ViewBag.Processes, page => Url.Action("Index", new { page }))
3.C#
public object Index(int? page) { var processes = System.Diagnostics.Process.GetProcesses(); var pageNumber = page ?? 1; var onePageOfProcesses = processes.ToPagedList(pageNumber, 25); ViewBag.Processes = onePageOfProcesses; return View(); }
4. 运行
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。