Reputation: 9298
I'm trying to generate a list of checkboxes, and make them checked if they exists for a product. Kinda like Products <-> ProductsCategories <-> Categories
Kinda like:
<%
foreach(var x in Model.Categories)
{
%>
<%= Html.CheckBox("CategoryID", checked if exists in Model.Product.Categories)%>
<%
}
%>
How is that done?
/M
Upvotes: 0
Views: 172
Reputation: 22867
<%= Html.CheckBox("CategoryID", Model.Product.Categories.Contains(x))%>
Hope that helps,
Kindness,
Dan
Upvotes: 1