MVC默认路由实现分页(PagerExtend.dll下载)(2)

using PagerExtend; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using System.Web.Security; namespace XinSheng.Api.Controllers { [Serializable] public class MoAirticle { public string Title { get; set; } public string Author { get; set; } public DateTime CreateTime { get; set; } } public class HomeController : Controller { public ActionResult Index(int id) { ViewBag.Title = "测试 分页"; List<MoAirticle> moAirticles = new List<MoAirticle>(); for (int i = 1; i < 50; i++) { moAirticles.Add(new MoAirticle { Author = "神牛步行" + i, CreateTime = DateTime.Now, Title = "博客园之" + i }); } ViewBag.Url = Request.RawUrl; //初始化分页基础信息 var option = new HtmlHelperExtensions.MoPagerOption { CurrentPage = id, PageSize = 15, Total = moAirticles.Count }; //动态传递分页属性 ViewBag.PagerOption = option; var articles = moAirticles.Skip((option.CurrentPage - 1) * option.PageSize).Take(option.PageSize).ToList(); return View(articles); } } }

D.分页PagerExtend.dll下载地址:PagerExtend.rar

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wjyxyd.html