Last post Dec 30, 2014 08:51 PM by gsmith4111
Dec 18, 2014 09:53 PM|gsmith4111|LINK
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.
Dec 22, 2014 03:28 AM|Fei Han - MSFT|LINK
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.
Dec 30, 2014 08:51 PM|gsmith4111|LINK
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:
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?