I have a view that uses a list of modelitems like this:
List<It4You.AlertBrick.Library.Domain.Order.AbOrderLineItemPicked>
When I get this list serverside I check if this is one type of item, it has to have a valid serial number. If its another type I check if the user has put a checkmark in the "picked" checkbox. If both of these fails, I would like to add a modelstate error to this row. What is the best way of doing this?
You can quite simply add directly into ModelState
as key/value pairs:
ModelState.AddModelError("error", "Serial is invalid");
and then in your view: @Html.ValidationMessage("error")
.