ActionLink sending a model of a complex type

ActionLink sending a model of a complex type

I'm trying to paginate the results of a "advanced search", I have a complex model that represents the search options;

int ZipCode int MinAge int MaxAge Availability     bool Monday     bool Tuesday     ...     bool Friday Requirements     bool FirstAid     bool DriversLicense 

I'm using;

<%: Html.ActionLink("Next »", "Save", "Notification", Model.options)%> 

Which correctly sends all the data at the first level, but anything that is a sub-object (Availability or requirements) isn't expanded in the URL, all I get is the class name and so I lose most of the search options when I click the link to change to a different page.

Any thoughts?

Style list of divs as 2 column layout with css


MVC2 DataAnnotations on ViewModel - Don't understand using it with MVVM pattern
Somewhere down the line your Options object gets used as an argument to the RouteValueDictionary constructor:.
Creating a 'website builder' - How would I architect it?
good/simple mvc application with fluent nhibernate
The code in that constructor does not recursively go down into the properties of your nested object.

Maintaining state and data context between requests
It only will reflect over the first level of your properties..
How can I use partial views in ASP.NET?

ASP.NET MVC 2 - Html.DropDownList not working in an AJAX form

Using Structuremap to manage ObjectContext Lifetime in ASP.NET MVC


I ended up creating a overridden ToString() method, which converted the complex model to a query string.

Then created a Flat model which mapped the query string and a convert method to pop me back out the original complex object.. I won't lie...

It's a lot of a hack.. But it all works, and rather reliably.


79 out of 100 based on 69 user ratings 1069 reviews