pagedlist - ASP.NET MVC Html.PagedListPager Not Working -
mycontroller:
public actionresult index(string searchstring, int? page) { var query = _mytable in _mydatacontext.mytables select _mytable; int pagesize = 10; // contain 10 products max because of pagesize int pagenumber = (page ?? 1); // if no page specified in querystring, default first page (1) pagedlist.pagedlist<mytables> models = new pagedlist.pagedlist<anlagen>(query, pagenumber, pagesize); return view(models); }
myview, last line:
@html.pagedlistpager(model, page => url.action("index", new { viewbag.searchstring, page}))
i don't know why, pagination is: «|‹|1|›|»
calling page "?searchstring=hello&page=2" works results, same pagination: «|‹|1|›|»
here search form:
<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>
just copy working project, in new project doesn't work :(
i believe have order elements pagedlist
work properly. adjust linq order collection value, such name
if exists:
var query = _mytable in _mydatacontext.mytables orderby _mytable.name select _mytable;
Comments
Post a Comment