现在,在视图文件的页面链接中,我有:
Page @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) of @Model.PageCount
@Html.PagedListPager(Model, page => Url.Action("Index",
new { page, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter, numberPerPage = ViewBag.numberPerPage, submit = ViewBag.submit }))
但是,由于人员搜索数据时的过滤器,参数可以更改,以便网址看起来像:
http://localhost:000/Search?Category=Cats&Category=Dogs&SearchString=brown&numberPerPage=10&submit=adoptable
如何将这些添加到视图页面?用户可能不使用过滤器。我通过ViewBag抓住它们,所以它们在html中就像:
cats,dogs
感谢。
答案 0 :(得分:0)
我想出了如何做我需要的事情。阅读时,特殊网址只能作为字符串附加到overflow-x:hidden
。所以我做的是:
Url.Action
在视图中:
public ActionResult Index(string SearchString, string sortOrder, string currentFilter, string numberPerPage, int? page, string[] Category)
{
..........
ViewBag.CategoryPager = "";
foreach (var singleCategory in Category)
{
ViewBag.CategoryPager += "&Category=" + Category.Replace(" ", "%20");
}
.........
return View(searchResults.ToPagedList(pageNumber, pageSize));
}