In my MVC4 project, I show the Checkbox and its corresponding Label so that when I click the label, the corresponding checkbox is checked. But when I use @Html.LabelFor , it displays the property name instead of showing its value. Also, when I click the label, the corresponding checkbox is not checked. What is wrong here?
@for (int i = 0; i < Model.AddOns.Count; i++) { @Html.CheckBoxFor(m => m.AddOns[i].IsActive) @Html.LabelFor(m => m.AddOns[i].Name) @Html.HiddenFor(m => m.AddOns[i].Id) }
When I use DisplayFor , it shows the value but the checkbox is not checked by clicking the label.
user1618825
source share