Avatar of Carla Romere
Carla Romere
Flag for United States of America

asked on 

Issue with DropDownList on FormView Edit

I have a simple Gridview and Formview set up on a couple of different pages. I use the FormView to edit existing records in the GridView or to add a new record. It works perfectly on one page, but on another one when I select the record in the Gridview that I want to edit in the FormView, I keep getting this error message:
'DropDownList1' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value

Open in new window

I can run SELECT DISTINCT WHS FROM AER_DOCK_APPOINTMENTS and I get three returned entries, each two characters long. In the DropDownList on the page, I have those same three two-character long choices as ListItems. The Insert from the FormView works perfectly.

CODE FOR DROPDOWN ON PAGE THAT WORKS
<asp:DropDownList ID="DropDownList1" runat="server" SelectedValue='<%# Bind("WAREHOUSE") %>'>
                                <asp:ListItem Selected="True"></asp:ListItem>
                                <asp:ListItem>LB</asp:ListItem>
                                <asp:ListItem>LP</asp:ListItem>
                                <asp:ListItem>SN</asp:ListItem>
                                <asp:ListItem>SS</asp:ListItem>
                                <asp:ListItem>WA</asp:ListItem>
                            </asp:DropDownList>

Open in new window


CODE FOR DROPDOWN ON PAGE THAT DOES NOT WORK
<asp:DropDownList ID="DropDownList1" runat="server" SelectedValue='<%# Bind("WHS") %>'>
                                <asp:ListItem Selected="True"></asp:ListItem>
                                <asp:ListItem>LB</asp:ListItem>
                                <asp:ListItem>SN</asp:ListItem>
                                <asp:ListItem>SS</asp:ListItem>
                            </asp:DropDownList>

Open in new window


What am I missing to figure this out?
ASP.NETC#Microsoft SQL Server

Avatar of undefined
Last Comment
Carla Romere

8/22/2022 - Mon