DropDownList - has a SelectedValue which is invalid because it doesnt appear in the list of items.
Posted on 2009-03-30
Experts Im stuck with a dropdownlist - I know it must be easy but I cant figure it out.
I have a dropdownlist (in a formview) with a list of our current sales people. It populates the field: sales_current.
This is fine until the record contains a sales person who has left and doesnt appear in my list. The drop down then throws this error:
'DropDownList5 has a SelectedValue Which is invalid because it doesnt appear in the list of items.'
Which makes sense really, but how do I work around this?
I dont want to list all the sales people that have left in my list.
<asp:DropDownList ID="DropDownList5" runat="server"
SelectedValue='<%# Bind("sales_current") %>'>
<asp:ListItem Value="">-Please Select-</asp:ListItem>