'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of items.

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.
jdcollins21Asked:
Who is Participating?
 
Easwaran ParamasivamCommented:
I hope you are selecting data for the dropdown list from database using SP/query. However you include the WHERE deactivated=0 condition in that.
Now you would get only active items.
0
 
jdcollins21Author Commented:
Thanks for your help. I woke up this morning with a similar idea. It works!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.