I have a model for which I would like to have a bulk update page, but I have problems.
My ViewModel:
public class ApproveView { public IEnumerable<MyObject> ObjectList { get; set; } }
In my opinion, I have:
foreach (var item in Model.ObjectList) { <div> <table class="form" width="100%"> <tr> <td>@Html.LabelFor(model => item.Accurate)<br /> @Html.RadioButtonFor(model => item.Accurate, true) Yes @Html.RadioButtonFor(model => item.Accurate, false) No @Html.ValidationMessageFor(model => item.Accurate) </td> <td> @Html.LabelFor(model => item.Comments)<br /> @Html.TextAreaFor(model => item.Comments)<br /> @Html.ValidationMessageFor(model => item.Comments) </td> </tr> </table> @Html.HiddenFor(model => item.ID) @Html.HiddenFor(model => item.CreatedOn) @Html.HiddenFor(model => item.CreatedBy) @Html.HiddenFor(model => item.ModifiedOn) @Html.HiddenFor(model => item.ModifiedBy) <hr /> }
This traverses my objects and prints a shape. The problem is that all fields of the same type have the same name. So, for example, all my switches are connected, and I can choose only one.
How to make the names for each field unique and associated with this object? Am I even on the right track or is there a better way to do this?
lovefaithswing
source share