ASP.NET MVC4 Razor模板简易分页效果(2)

public ViewResult Index(int? pageIndex ,string search)   {   int pageInd = pageIndex.HasValue ? pageIndex.Value : 1;   ViewBag.PageCount = (int)Math.Ceiling(result.Count() / 20.0);   return View(result.OrderBy(t => t.PID).Skip((pageInd - 1) * 20).Take(20));   }

视图(页面调用):
 @using (Html.BeginForm())

根据性别得到查询结果 

性别: @Html.TextBox("sex")

<input type="submit" value="查询" />  

@Html.Action("PageIndexKey", "PageIndex", new { pageCount = ViewBag.PageCount, currentPage = ViewBag.CurrentPage })
 

Example: 

    //数据,一个list的集合     List<string> s = new List<string>(); s.Add("张军"); ViewBag.PageCount = (int)Math.Ceiling(s.Count() / 20.0); return View(s.Skip((pageInd - 1) * 20).Take(20));     @Html.Action("PageIndex", "PageIndex",     new { action = "", controller = "", pageCount = ViewBag.PageCount, currentPage = ViewBag.CurrentPage })

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

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