Retrieve checkbox values in viewmodel
Posted
by Dean Ouellette
on Stack Overflow
See other posts from Stack Overflow
or by Dean Ouellette
Published on 2010-05-03T15:07:55Z
Indexed on
2010/05/03
17:38 UTC
Read the original article
Hit count: 426
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
© Stack Overflow or respective owner