locked
'Value' has a SelectedValue which is invalid because it does not exist in the list of items. RRS feed

  • Question

  • User47306736 posted

    Here we go.... i have this dropdown box in listview when it was null it was working ok no problem,upon field update everything work fine.

    problem apper the next time i tried to update the listview will show the recored but when click on edit it give me the following error.

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

    it explain why so i check my list of item and here is how it is look like

                <asp:DropDownList ID="Drop" runat="server" Text='<%# Bind("Drop") %>'>
                    <asp:ListItem></asp:ListItem>
                    <asp:ListItem>Yes</asp:ListItem>
                    <asp:ListItem>No</asp:ListItem>
                </asp:DropDownList>

    the value in the table is No so it is in the list of item, i can not understand why it still give me this error, i even try to delete the No from the table but did not help

    Any advice will be appreciated


     

    Saturday, September 28, 2013 10:09 AM

Answers

  • User-1716253493 posted
    Null issue i guess, include value="" Text ="Not Set" to the DropDownList. Then SelectedValue ='<%# Bind("Drop") %>'
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, September 28, 2013 10:43 AM

All replies

  • User-1716253493 posted
    Try removing space before Yes and No. Make sure the data doesn't contain null value. If any, add also blank item to DropDownList.
    Saturday, September 28, 2013 10:24 AM
  • User47306736 posted

    Removing space where ? on the table ? and yes i have null value and i did add an blank item that help when i start to work on it but after an update it stop working too

     OK my field is navchr(10) i change it to 3 and it is working better is there anyway that i will not mind the spaces ?

     

    Saturday, September 28, 2013 10:30 AM
  • User-1716253493 posted
    Null issue i guess, include value="" Text ="Not Set" to the DropDownList. Then SelectedValue ='<%# Bind("Drop") %>'
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, September 28, 2013 10:43 AM