I tried to inject IDataErrorInfo into my partial classes, but I still got the error message "Value is required" for dropdownlists, for which nothing was selected in it, i.e. The return value is null, not an integer for the foreign key.
I did this in the first line of my Create action:
public ActionResult Create([Bind(Exclude="Id")]MyEntity myEntityToCreate) { foreach (string key in ModelState.Keys) { ModelState[key].Errors.Clear(); }
and then rely on my model authentication code, which runs when the object is saved, to add meaningful error messages to the ModelState collection when the dropdowns are not selected.
This is probably not the best way to do this.
Marcemarc
source share