I have a viewmodel class that contains a couple of properties. Basically, the current record (which the user edits) and the parameter list (which is used to populate the drop-down list using DropDownListFor).
After submitting the form, if the state of the model is invalid, I return to the view. I understand that the form is populated using the βrejectedβ input from ModelState["name"].Value.AttemptedValue , but I'm not sure what to do with the list of values ββfor the drop-down list.
If I do nothing, when checking fails and returning to the page, I get the error "link to an object not installed in the object instance", because the list property for viewmodel is null. I know that it is null because it was not associated with the form post, so I can re-populate it from the database before returning to the view.
Is this the right way to get around this, or am I skipping the more obvious way to make the dropdown values ββpersist?
asp.net-mvc-2
Gavin
source share