title: How can I edit child objects in an MVC4 form?
body: <p>I have the following: </p>
  
  <pre><code>@foreach (var parent in Model.Parents)
  {      
      @foreach (var child in parent.Children)
      {    
          @Html.TextAreaFor(c =&gt; child.name)    
      }                   
  }
  </code></pre>
  
  <p>How can I get editing to work for child objects?  I tried something like this as well: </p>
  
  <pre><code>&lt;input type="hidden" name="children.Index" value="@child.Id" /&gt;
  &lt;textarea name="children[@child.Id]" &gt;@child.Name&lt;/textarea&gt;
  </code></pre>
  
  <p>To pass an IDictionary to the controller but I get an error: </p>
  
  <pre><code>[InvalidCastException: Specified cast is not valid.]
     System.Web.Mvc.CollectionHelpers.ReplaceDictionaryImpl(IDictionary`2 dictionary, IEnumerable`1 newContents) +131
  </code></pre>
  
  <p>This seems like a very common task... is there a simple solution to this?  What am I missing?  Do I need to use an Editor Template?  If so, any MVC4-compatible examples would be fantastic. </p>