Note that there are some explanatory texts on larger screens.

plurals
  1. POBinding to a List property of a Model
    primarykey
    data
    text
    <p>I have the following Model</p> <pre><code>public class FooContainer { public int ID { get; set; } public string Name { get; set; } public IList&lt;Foo&gt; Foos { get; set; } } public class Foo { public string Name {get; set; } public string Description {get; set;} } </code></pre> <p>Example Controller</p> <pre><code>public class FooController : Controller { public ActionResult Index(){ return View(new FooContainer()); } [HttpPost] public ActionResult Index(FooContainer model){ //Do stuff with the model } } </code></pre> <p>I want to create a view which enables the user to CRUD Foos.</p> <p><strong>Existing Research</strong></p> <p>I have read the following:<br/> <a href="http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx" rel="nofollow noreferrer">http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx</a> <a href="http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx" rel="nofollow noreferrer">http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx</a></p> <p>along with the following SO articles<br/> <a href="https://stackoverflow.com/questions/14648035/mvc4-allowing-users-to-edit-list-items">MVC4 Allowing Users to Edit List Items</a> <br/> <a href="https://stackoverflow.com/questions/14750946/mvc4-bind-model-to-icollection-or-list-in-partial">MVC4 bind model to ICollection or List in partial</a></p> <p>So i know how to pass an IEnumerable&lt;> back and forth, the problem is that i want to pass some container, with other attributes <em>including</em> an IEnumerable&lt;></p> <p><strong>Requirement</strong> <br/> I want to be able to bind to this complex model so that it is passed completely and in its entirety to the controller. Assume that the controller does nothing but render the view and receive the FooController model on post. Additionally i would like any relevant articles or references to View syntax required to enable this.</p> <p>Thanks in advance</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload