'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of items.
Posted on 2011-09-06
This is a question I'm seeing quite a bit and I'm not seeing a perfect fit answer. I've got a form with a series of dropdowns fed by sql datasources in an asp.net page. They pull from different tables.
The problem I've got it that if one of the items in my table gets "deactivated" from my list, it will spit out this error if someone goes to look at an old record where it was picked.
I'm experiencing that very thing right now in a test. I'm looking for something quick and clean to either add the item/ ignore(?) the error and just not display a value/ a good rational solution.
"deactivated" = I only flag things as "deactivated" most of the time as opposed to deleting them. The table's not that big even with the "deactivated" records. My datasources filter these out.