Checkbox foreach item in the list
I have a form to insert products into the database (by the moment I only put the product name):
using (Html.BeginForm())
{
<fieldset>
<legend>Fields</legend>
<div>
@(Html.LabelFor(e => e.Name))
@(Html.TextBoxFor(e => e.Name))
@(Html.ValidationMessageFor(e => e.Nam开发者_开发问答e, "Wrong name:please check"))
</div>
</fieldset>
}
What I would like now is how should I compose the form in order to show my database list of categories, showing a checkbox foreach category.
In my Product model I have a property List<Category>
that I would like to complete with the chosen checkboxes from the user. But I don't know how to receive in my action the model with the property set.
How to solve this?
精彩评论