This has to be a very simple request, but I just started using your RAD Ajax ASP combo box...
I have a combobox that is bound to a list of States.
- I am setting the DataValueField to an integer that is basically an identity value in the database.
- I am setting the DataTextField to the abbreviations of the State.
When a user fills out the form and saves the data to a database, we are saving the DataTextField , not the value field. So, we'd save "NC" or "NY" for instance, instead of the integer of 37 or 39 or whatever corresponds to that state.
BTW: After the user selects a state, I use the SelectedValue to find a list of Counties that belong to that state.
Here is what I don't know how to do:
- In our app, the user can pull up this data to edit it. Since they have previously selected a State, I need to select the value of the state that they had chosen, in the Combobox.
Q. How can I do that? I fill the combo box with a list of States, but if I set the "SelectedItem.Text" to the state abbreviation that they had chosen, it obviously sets the text of the first item in the combobox to their state.
But that is wrong. I want to programmatically select the state that they had selected, in the combox box.
- Since I only have the State abbreviation (the DataTextField) and
not the ID, I can't set the "SelectedValue" (if that would even do what I want).
I guess the question boils down to: If I have a combo box full of string values, how can I programmatically select an item from the combo box, based on that string value?
Thanks,
Brent
I have a combobox that is bound to a list of States.
- I am setting the DataValueField to an integer that is basically an identity value in the database.
- I am setting the DataTextField to the abbreviations of the State.
When a user fills out the form and saves the data to a database, we are saving the DataTextField , not the value field. So, we'd save "NC" or "NY" for instance, instead of the integer of 37 or 39 or whatever corresponds to that state.
BTW: After the user selects a state, I use the SelectedValue to find a list of Counties that belong to that state.
Here is what I don't know how to do:
- In our app, the user can pull up this data to edit it. Since they have previously selected a State, I need to select the value of the state that they had chosen, in the Combobox.
Q. How can I do that? I fill the combo box with a list of States, but if I set the "SelectedItem.Text" to the state abbreviation that they had chosen, it obviously sets the text of the first item in the combobox to their state.
But that is wrong. I want to programmatically select the state that they had selected, in the combox box.
- Since I only have the State abbreviation (the DataTextField) and
not the ID, I can't set the "SelectedValue" (if that would even do what I want).
I guess the question boils down to: If I have a combo box full of string values, how can I programmatically select an item from the combo box, based on that string value?
Thanks,
Brent