PagedList分页,如何添加action参数

使用PagedList分页,如

@Html.PagedListPager((IPagedList)Model, page => Url.Action("Index", new { page = page }))

  

随后用到了时间搜索

<div class="search_title">来访时间</div>
@Html.TextBox("StartTime", ViewData["StartTime"], new { type = "text"})
<div class="search_title">至</div>
@Html.TextBox("EndTime", ViewData["EndTime"], new { type = "text"})

  

怎么把搜索条件传入到action呢?

可使用ViewData解决:

@Html.PagedListPager(Model, page => Url.Action("Index", new {page, StartTime = ViewData["StartTime"], EndTime = ViewData["EndTime"]}))

参考网站:http://q.cnblogs.com/q/45680/

原文地址:https://www.cnblogs.com/zhucheng88/p/5681374.html