locked
DropDownList Box: SelectedValue which is invalid because it does not exist in the list of items. RRS feed

  • Question

  • User1291440890 posted

    Hi

     

    Using VS2005, SQL Server 2005, FormView

     

    I am using the following code to insert a blank at the start of the my dropdownlist box and this works fine

     

    <asp:DropDownList ID="VersionDropDownList" runat="server" AutoPostBack="True"  AppendDataBoundItems="true" DataSourceID="SqlDataSource4"

    DataTextField="Version" DataValueField="VersionID" SelectedValue='<%# Bind("VersionID") %>'

    Width="154px">

    <asp:ListItem Value=""></asp:ListItem>

    </asp:DropDownList></td>

     

    On Update, if the dropdownlist is NOT selected, a Value of Zero is updated in DataValueField="VersionID" as expected.

     

    How do I account for the zero value next time I open the FormView?

     

    Currently I am geting the following error

     

    'VersionDropDownList' has a SelectedValue which is invalid because it does not exist in the list of items.
    Parameter name: value

     

    Could someone shed any light?

     

    Thanks in advance

    Wednesday, September 6, 2006 3:52 AM

Answers

All replies