Retrieve checkbox values in viewmodel
- by Dean Ouellette
This question has been asked many times but none that I really understand.
I have a checkbox list in a generated table.
I want to submit the form and retrieve the checkbox values and capture the checked boxes.
In the view:
<% foreach (var item in Model.Results)
{ %
<%= Html.CheckBox("selectedItem", new { value = item.ItemId })%
<% } %
In the viewmodel, how should I declare "selectedItem"? as a Inumerable, Int[], ....
In the controller I want the viewmodel to contain the list of objects that are selected,so I can submit to the database.
Thanks,
Dean