ekynox
ekynox

Reputation: 459

MVC 3 - parse FormCollection to model

For my sample application I am building I am currently forced to pass a FormCollection object into my action method when attempting to do ajax updates on my view.

The reason I have chosen to pass FormCollection is that my view is rather complex and contains nested collections. If I were to Serialize and Json.Stringify it drops these nested collections when passed into my action method.

Is there a good technique to map my FormCollection object to an instance of my ViewModel once inside the controller ?

thanks

Upvotes: 4

Views: 2559

Answers (1)

ajay_whiz
ajay_whiz

Reputation: 17931

You can use TryUpdateModel<TypeOfYourModel>(YourModelInstance)

Upvotes: 2

Related Questions