No, this really doesn't answer my question. I'm aware of how to use a strongly typed collection of objects to a view ... what I'm asking is, "Is it possible to put that collection of objects together in a single form and pass them back to a create/edit
action method that automatically binds the values to the correct objects for persisting?"
So, lets say I have a form that has data for a Person object and a collection of ContactInfo objects. I'd like to do something like prefix all the person object data with "person" and post it, along with all the contactInfo object data (prefixed by "contactInfo"
and all loaded into a dictionary named "Contacts") to an action method such as public ActionResult Create (Person person, ContactInfo[] contacts) {}
This is pretty easy to do in Rails but I'm not sure if it is possible ... or if so ... what is the best way to do it in ASP.NET MVC.
wgpubs
Member
15 Points
12 Posts
Re: Bind to multiple objects?
Nov 22, 2008 04:05 PM|LINK
No, this really doesn't answer my question. I'm aware of how to use a strongly typed collection of objects to a view ... what I'm asking is, "Is it possible to put that collection of objects together in a single form and pass them back to a create/edit action method that automatically binds the values to the correct objects for persisting?"
So, lets say I have a form that has data for a Person object and a collection of ContactInfo objects. I'd like to do something like prefix all the person object data with "person" and post it, along with all the contactInfo object data (prefixed by "contactInfo" and all loaded into a dictionary named "Contacts") to an action method such as public ActionResult Create (Person person, ContactInfo[] contacts) {}
This is pretty easy to do in Rails but I'm not sure if it is possible ... or if so ... what is the best way to do it in ASP.NET MVC.
Thanks - wg