ASP.NET MVC DropDownList Validation
- by Andrew Florko
Hello everybody,
I have
[DisplayName("Country")]
public List<SelectListItem> Countries { get; set; }
property in Model class for DropDownList.
When I try to check if the ModelState.IsValid on form postback it's always false & error for Countries tells "Can't convert [value] to SelectListItem" or some of a kind.
I figured out there is no straight-forward mapping for drop down selected value (looks like I'll have to read value from Form value collection), but how can I ignore binding and validation for List property? I just want to make ModelState.IsValid attribute to be true if all the other fields are populated properly.
Thank you in advance