0
In an ASP.NET C# MVC4 system I have some screens where I show some data. These screens have Filters and navigation (maximum limit of 10 data per page). I would like to know how I can record Formcollection in some way so that it passes in pagination. An example of my control:
public ActionResult Orcamentos(int? page)
{
}
public ActionResult Orcamentos(int? page, FormCollection form)
{
}
Within these methods I already do everything right, working properly and showing in the View correctly. Now in the View that is the problem, in the navigation of the pages I can pass the Form so that it enters the method with Form.
In View, the Pagination part is like this:
@Html.PagedListPager(Model, (page) => Url.Action("Index", new { page = page, form = @ViewBag.filtro }), PagedListRenderOptions.Classic )
So where ta @Viewbag.filter I would have to find a way to pass the Formcollection (I pasted the Viewbag just by example, because it cannot store the form)
pageusually comes from aGET.FormCollectionusually comes from aPOST. What is the purpose of this implementation?– Leonel Sanches da Silva
When displays the data in the View, and it is paged, when I click on a page number there, for example 3, I send page=3 and also need to send the Form because I made a Filter. The pagination code would be this: (where I put Viewbag.Filter I would have to pass a Formcollection @Html.Pagedlistpager(Model, (page) => Url.Action("Index", new { page = page, form = @Viewbag.filter }), Pagedlistrenderoptions.Classic )
– RafaelMoura
It’s wrong. If you want to set a filter, it has to be by
GETalso, and not usingFormCollection. Either you use named parameters or you useFormCollection. The two of them together don’t make it. If I were you, I’d use one Viewmodel defining not only the filter, but the page in question.– Leonel Sanches da Silva