title: MVC2 Modelbinder for List of derived objects
body: <p>I want a list of different (derived) object types working with the Default Modelbinder in Asp.net MVC 2.</p>
  
  <p>I have the following ViewModel:</p>
  
  <pre><code>public class ItemFormModel
      {       
          [Required(ErrorMessage = "Required Field")] 
          public string Name { get; set; }
          public string Description { get; set; }
  
          [ScaffoldColumn(true)]
          //public List&lt;Core.Object&gt; Objects { get; set; }       
          public ArrayList Objects { get; set; }                  
      }
  </code></pre>
  
  <p>And the list contains objects of diffent derived types, e.g.</p>
  
  <pre><code>public class TextObject : Core.Object
      {
          public string Text { get; set; }
      }
  
      public class BoolObject : Core.Object
      {
          public bool Value { get; set; }
      }
  </code></pre>
  
  <p>It doesn't matter if I use the List or the ArrayList implementation, everything get's nicely scaffolded in the form, but the modelbinder doesn't resolve the derived object type properties for me when posting back to the ActionResult.</p>
  
  <p>What could be a good solution for the Viewmodel structure to get a list of different object types handled? Having an extra list for every object type (e.g. List, List etc.) seems to be not a good solution for me, since this is a lot of overhead both in building the viewmodel and mapping it back to the domain model.</p>
  
  <p>Thinking about the other approach of binding all properties in a custom model binder, how can I make use the data annotations approach here (validating required attributes etc.) without a lot of overhead?</p>