查看
//Some Codes in my VIEW
@foreach (var item in Model._oList)
{
//Grid table code
}
@Html.PagedListPager((IPagedList)ViewBag.activityList , page => Url.Action("Solution",new { page }),PagedListRenderOptions.OnlyShowFivePagesAtATime)
CONTROLLER
//For my pagination Code
var pageNumber = page ?? 1;
var onePageNumberBugs = _oList.ToPagedList(pageNumber, 5);
ViewBag.activityList = onePageNumberBugs;
首次加载我的页面
(URL:) http://localhost:50969/Home/Solution?value=00003%20
当我从我的页面点击我的分页时,URL将是
(URL:) http://localhost:50969/Home/Solution?page=2
我的问题是,我如何制作这样的网址:
(URL:) http://localhost:50969/Home/Solution?value=00003%20&page=2
或
(URL:) http://localhost:50969/Home/Solution?page=2&value=00003%20
这样我就可以将我的值用于我的控制器用于其他目的。
答案 0 :(得分:1)
要保留value
,您应该更改您的分页链接,如下所示:
@Html.PagedListPager((IPagedList)ViewBag.activityList , x => Url.Action("Solution",new {value = ViewBag.StoredValue, page = x}),PagedListRenderOptions.OnlyShowFivePagesAtATime)
你的行动将如下:
public ActionResult Solution(string value, int? page)
{
ViewBag.StoredValue = value;
//do what you want to do here
}
这里的诀窍是将查询字符串中的value
缓存到ViewBag
并在您的分页链接中使用它。因此,无论何时转到新页面,您都会将当前value
传递给您的操作
答案 1 :(得分:1)
尝试从视图
发送查询字符串中的值@Html.PagedListPager((IPagedList)ViewBag.activityList , page => Url.Action("Resolution",new { page,value=YOURVALUE }),PagedListRenderOptions.OnlyShowFivePagesAtATime)
答案 2 :(得分:1)
最好将值作为MODEL传递
@Html.PagedListPager((IPagedList)ViewBag.activityList , page => Url.Action("Solution",new { Model.variable_name ,page }),PagedListRenderOptions.OnlyShowFivePagesAtATime)
<强> CONTROLLER 强>
public ActionResult Resolution(int? page, SolutionModel _oSolutionModel)
{ /*Some codes*/ }
答案 3 :(得分:0)
这适合我。
@Html.PagedListPager(Model, p => Url.Action("", "Solution/" , new { p, tanz = Request.Params["value"] }))