I\'m trying to model bind a set of dynamically generated checkboxes so as to process them in the controller action but can\'t get the model binding to occur. This is the scenari
If you are binding your checkboxes to a Dictionary
try this:
<% var i = 0; %>
<% foreach (KeyValuePair categoryCheckbox in Model.CategoryCheckboxes) {%>
" value="<%= categoryCheckbox.Key %>" />
<%= Html.CheckBox(String.Format("CategoryCheckboxes[{0}].Value", i), categoryCheckbox.Value) %>
<% i++; %>
<% } %>
Hope this helps
UPDATED:
For binding to IDictionary
your form must contain inputs with "CategoryCheckboxes[n].Key" and "CategoryCheckboxes[n].Value" Ids/Names, where n must be zero-based and unbroken.