【发布时间】:2016-01-28 14:40:05
【问题描述】:
我的控制器:
public ActionResult Index(String SearchString, int? page)
{
var query = from _mytable in _MyDataContext.MyTables select _mytable;
int pageSize = 10; // will only contain 10 products max because of the pageSize
int pageNumber = (page ?? 1); // if no page was specified in the querystring, default to the first page (1)
PagedList.PagedList<MyTables> models = new PagedList.PagedList<Anlagen>(query, pageNumber, pageSize);
return View(models);
}
MyView,最后一行:
@Html.PagedListPager(Model, page => Url.Action("Index", new { ViewBag.SearchString, page}))
我不知道为什么,但唯一的分页是: «|‹|1|›|»
使用“?SearchString=hello&page=2”调用页面效果很好,但分页相同: «|‹|1|›|»
这是我的搜索表单:
<form action="@Url.Action("Index", "Anlagen")" method="get" role="search" class="navbar-form-custom">
<div class="form-group input-group">
<input type="text" class="form-control" placeholder="suchen..." id="SearchString" name="SearchString" value="@ViewBag.SearchString" />
</div>
</form>
只是一个工作项目的副本,但在一个新项目中它不起作用:(
【问题讨论】:
标签: asp.net-mvc pagedlist