c# - MVC 3 WebGrid Paging doesn't return orginal search results -
c# - MVC 3 WebGrid Paging doesn't return orginal search results -
i have search page on load fills webgrid. issue paging. on load fill grid "non published" articles (there none in case). search "currently published) , 3 rows.
now have 3 pages (i set paging 1 row per page testing purposes). first time searches - gets right answers in grid,a nd lets there 2 pages.
if click 2 go sec page - grid fills criteria of load - non published of there none. see not going httppost action on page click - not sure why this.
you can see have initial load called admin , post called admin(formcollection values) on both set defaults "not published"
public actionresult admin() { var menus = ( p in db.menus.tolist() p.parentid == 0 orderby p.order ascending select p.name ); viewbag.menus = new selectlist(menus, "home"); string[] publishedstatuses = new string[3] { "not published", "expired already", "currently published"}; viewbag.published = new selectlist(publishedstatuses, "not published"); var articles = ( p in db.articles.tolist() p.publishtoweb == false && p.menu == "home" select p ); } homecoming view(articles); } }
your problem here link you're clicking page phone call admin controller action again, , since you're not receiving parameters initial search again.
if alter action method as:
public actionresult admin(int? page) { //your code here }
you page number web grid , can utilize in search. enable filtering , searchgin, have @ blog post:
http://www.elylucas.net/post/using-a-grid-that-can-sort-page-and-filter-in-aspnet-mvc3e28093part-1e28093using-the-webgrid-webhelper.aspx
c# asp.net-mvc webgrid
Comments
Post a Comment