<% foreach (FoodMenu f in (IEnumerable)ViewData.Model) { %> <ul > <li><%= Html.Encode(f.ProductId) %> </li> <li><%= Html.Encode(f.Name) %></li> <li><%= Html.Encode(f.Price) %> </li> <li><%= Html.CheckBox('Selected') %></p></li> </ul> </div> <% } %>
I want to add the selected item into database
Encode the id of the product that is selected into the name of the check box.
The on the server side, iterate through the ValueProviderKeys and find selections and extract the product id from the ones that are selected.