I have this ASP:NET MVC Razor View which has a IEnumerable as model .
I'm creating a table where each line represents a item from the IEnumerable.
I'm using this code:
@foreach (var item in Model)
{
<tr>
<td>
<input type="checkbox" name="selectedFoo" value="@item.isAdded"
@(Html.Raw(item.isAdded? "checked=\"checked\"" : "")) />
@item.FooName
</td>
<td>
@Html.EditorFor(modelItem=> item.Name, new { htmlAttributes = new { @class = "form-control", style = "width: 70px" } })
@Html.ValidationMessageFor(modelItem=> item.Name, "", new { @class = "text-danger" })
</td>
</tr>
}
My problem is that when I enter an incorrect value for the "Name" property all the other text input get the validation error.
Solutions?
Thank you.