Problem: I have a page that displays list of items. And user can filter the items by create date, title, etc. For example: Blog List @using (Html.BeginForm("List", "Blog")) { @Html.EditorFor(m = m.Filter.CreateDate) @Html.EditorFor(m = m.Filter.Title) // Table ... } The action looks something like this: public ActionResult List(BlogListFilter filter) { var filter = filter ?? new BlogListFilter(); var model = new BlogListViewModel { Filter = filter, Blogs = _blogService.GetBlogsByFilter(filter) }; return View(model); } It works well until i want to add a pager compent for the table because the list of blogs is too large. @using (Html.BeginForm("List", "Blog")) { @Html.EditorFor(m = m.Filter.CreateDate) @Html.EditorFor(m = m.Filter.Title) // Table ... @Html.PagerFor(m = m.Paging) } The problem occurs when clicking on the page number to jump to another page. The filter turn out be not working anymore in this case. public ActionResult List(BlogListFilter filter, int page = 1) { var filter = filter ?? new BlogListFilter(); // .
I guess you came to this post by searching similar kind of issues in any of the search engine and hope that this resolved your problem. If you find this tips useful, just drop a line below and share the link to others and who knows they might find it useful too.
Stay tuned to my blog, twitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.
Stay tuned to my blog, twitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.
This article is related to
Better code,ASP.NET MVC,HTTP GET,HTTP POST
Better code,ASP.NET MVC,HTTP GET,HTTP POST
No comments:
Post a Comment