design patterns - ASP.NET MVC Paging for a search form -


I have read many different positions on paging / MVC but do not describe any such scenario where I have Something like a search form and then after collecting the user clicks, you want to display the results of the search criteria (with paging) below the form.

My problem is that, I am using paging solutions & lt; A href = "..." & gt; Links which will pass the desired page as well: And when this is all right and the banks are not the result of the query sent to DB in memory or something, so I have to ask DB again.

If the post / controller's action is taken for the result / search and the first page of the data is presented as such, then the same result (user specified by the user when I clicked it) How to get the form criteria? To go to page 2?

Some javascript magic? Levitation session state? I GET controller action of the search criteria (but required by alternative) is a variable, when asked GET verb, try to be a FormCollection instance immediately, to populate it and post methodology (cache satisfactory DRY Pass on?

Can anyone tell me in the right direction for this scenario or provide examples which have been implemented in the past? Thanks!

My method is an action that handles both post and landscape.

It can be controlled by both mine that GET and POST methods:

  public view Result Index ([DefaultValue (1)] Int page, [DefaultValue (30)] int Pejasis, string search, [DefaultValue (0)] int regionId, [DefaultValue (0)] integer eventTypeId DATETIME ,, to date time?) {var events = EventRepo.GetFilteredEvents (page, pageSize, Search, regionId, eventTypeId, from my service); Var EventFilterForm = EventServicesService GetWinterFilterform (from, to); Var Event IndexModel = New Event Index Model (Event, EventFilterForm); See Return ("Index", Event Index Model); }  

eventFilterForm that contains some IEnumerable & lt; a presentation model; SelectListItem & gt; Properties for my search form

< eventIndexModel is a presentation model that adds eventFilterForm and search results - Events

events is a special type of IPagedList . You can get more information and code for that and the first link conversation about IPagedList where there is an advanced paging scenario of the other link that you need.

And if I like it then use:

  & lt; % = Html.Pager (Model.Events.PageSize, Model.Events.PageNumber, Model.Events.TotalItemCount, new {action = "index", controller = "search" Search = ViewData.EvalWithModelState ( "Search"), regionId = ViewData.EvalWithModelState ( "regionId"), eventTypeId = ViewData.EvalWithModelState ( "EventTypeId"), a = ViewData.EvalDateWithModelState ( "the" for "), = ViewData.EvalDateWithModelState the (")})% & Gt;  

This link makes that look like:

/ Event / Search regionId = 4 & amp; EventTypeId = 39 & amp; = 2009/09/01 & amp; To do = 2010/08/31 and page = 3

HTH,
Charles

PS EvalWithModelState is below:

PP If you put dates in a variable - I would recommend reading it ...: -)

  /// & lt; Summary & gt; /// ViewData will get the specified key. It will look at the first modelstate /// and if it does not get it, then it will call ViewData.Eval (string key) /// & lt; / Summary & gt; /// & lt; Ultimate name = "View data" & gt; ViewDataDictionary Object & lt; / Param & gt; /// & lt; Param name = "key" & gt; Key dictionary & lt; / Param & gt; /// & lt; Returns & gt; Value in the model if it finds or ViewData.Eval () & lt; / Returns> Public static string EvalWithModelState (it ViewDataDictionary Drishydeta, String key) {if (viewData.ModelState.ContainsKey (key)) returnData.ModelState [key] .Value.AttemptedValue; Return (ViewData.Aval (Key)! = Null)? ViewData.Eval (key) .ostring (): string.Empty; }  

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -