locked
How allow items in combobox/dropdownlist that aren't in the list RRS feed

  • Question

  • User1487036412 posted

    I am converting an Access database to an ASP web page.  One field contains a list of people. I want the dropdown to only contain certain people, but there is already allot of names that are not those certain people.  I want to allow the old data to stay in the database, but any new ones, or if they edit and change the current name, I want it to have to be in the list, but if they don't change it the name, I don't want it to throw an error.

       I have my SelectedValue='<%#bind("RequestedBy")%>'.  

    If the data in the database is in the list, it works fine.

    If the data in the field is not in the list, I get an error, because combobox has a selectedvalue which is invalid because it does not exist in the list of items.

    How do I just ignore it if the name isn't in the list? I want the name to stay in the box, even if its not in the list. Only if I try to change it, do I want to have to choose from an item in the list.

    Thursday, December 18, 2014 9:53 PM

Answers

  • User61956409 posted

    Hi gsmith4111,

    Thanks for your post.

    Firstly, what is the error message you got? You could show us your error message, it will help us to focus right direction to resolve the problem.

    Secondly, if you’d like to bind “RequestedBy” to SelectedValue, you should ensure the data source contains this field.

    If you have any question about my reply, please let me know freely.

    Best Regards,

    Fei Han

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 22, 2014 3:28 AM

All replies

  • User61956409 posted

    Hi gsmith4111,

    Thanks for your post.

    Firstly, what is the error message you got? You could show us your error message, it will help us to focus right direction to resolve the problem.

    Secondly, if you’d like to bind “RequestedBy” to SelectedValue, you should ensure the data source contains this field.

    If you have any question about my reply, please let me know freely.

    Best Regards,

    Fei Han

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 22, 2014 3:28 AM
  • User1487036412 posted

    Thank you for the reply. Sorry to be so slow getting back.  The Holidays have kept me away from programming.  

    Here is the actual error message:

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

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.ArgumentOutOfRangeException: 'Requester_ComboBox' has a SelectedValue which is invalid because it does not exist in the list of items.
    Parameter name: value

    As for the second part, the field RequestedBy is in the data source, and the combo box works fine, as long as the data is one of the names already in the source.  Like I said, I only get the error if one of the values is not in the list. This database has been around for a few years, and has allot of data in it. I am converting it from an Access mdb to a website, and the Access combobox is what I am trying to convert. The Access query gives a list of names to select from, but also allows the user to enter their own data in, I believe it uses the "LimitToList=NO".  so how can I use a combo box in the ASP page that doesn't give me an error if the value is not in the list?

    Thank you

    Tuesday, December 30, 2014 8:51 PM