I am trying to write a custom model binder but I\'m having great difficulty trying to figure how to bind complex composite objects.
this is the class I\'m trying to
Do you really need to implement a custom ModelBinder here? The default binder may do what you need (as it can populate collections and complex objects):
Lets say your controller action looks like this:
public ActionResult SomeAction(Fund fund)
{
//do some stuff
return View();
}
And you html contains this:
The default model binder should initialise your fund object with 2 items in the FundAllocations List (I don't know what your FundAllocation class looks like, so I made up a single property "SomeProperty"). Just be sure to include those "fund.FundAllocations.Index" elements (which the default binder looks at for it's own use), that got me when I tried to get this working).