I'm creating an inventory of locks, each lock has a serial number (Title), an associated school (SchoolCode), and 5 associated Combinations (having Number, Combination, and IsActive). We're using Ncommon and linq and have set them up as nested entities (Lock Has Many Combinations).
On the form, I'm using JQuery Templates to dynamically build the form. Where SchoolCode and Title are basic form elements, Combinations[index].Number and Combinations[index].Combination are the sub-elements.
<form method="post" action="/Lockers.aspx/Locks/Add">
<input type="hidden" name="SchoolCode" value="102">
Lock S/N: <input type="text" name="Title" value=""><br>
<div id="combinations">
<input type="hidden" name="Combinations[0].Number" value="1">
<input type="text" name="Combinations[0].Combination" value="">
<input type="radio" value="1" name="ActiveCombination"><br>
<input type="hidden" name="Combinations[1].Number" value="2">
<input type="text" name="Combinations[1].Combination" value="">
<input type="radio" value="2" name="ActiveCombination"><br>
<input type="hidden" name="Combinations[2].Number" value="3">
<input type="text" name="Combinations[2].Combination" value="">
<input type="radio" value="3" name="ActiveCombination"><br>
<input type="hidden" name="Combinations[3].Number" value="4">
<input type="text" name="Combinations[3].Combination" value="">
<input type="radio" value="4" name="ActiveCombination"><br>
<input type="hidden" name="Combinations[4].Number" value="5">
<input type="text" name="Combinations[4].Combination" value="">
<input type="radio" value="5" name="ActiveCombination"><br></div>
<input type="submit" id="add" value="Add »"> <br>
</form>
When I run this without the Bind attribute, model binding works fine. Once I add the bind, I can't seem to have it bind to any of the Combinations.
[HttpPost]
public ActionResult Add([Bind(Include = "SchoolCode,Title,Combinations.Combination,Combination.Number,Combinations[2].Combination")] LockerLock @lock, [Range(1, 5)] int ActiveCombination)
{
...
}