Datasource provides a list of values to load the combo box. Plain-vanilla VB.Net code.
This combo box is used in an edit form, and the selected value is set when the record to be edited is read from the SQL Server database.
We are not using any type of binding.
So, when I attempt to initialize the combo when the page loads, I find that I have a value in the database that triggers an error that is not trapped by a traditional Try / Catch construct. (see attachment)
In this particular example, the code found in the database did not match any value in the datasource for this combo and I get a hard, untrapped error on the selected value assignment. ("selection out of range")
I am hoping that I am doing something really stupid and overlooking an obvious solution, anybody care to show me my error?
Note: I am aware that I can set "allow custom text" but that is not the intent, rather to insulate my page from data errors, and allow for corrections by setting the selected value to nothing and letting the user make a proper selection. But if that is the only way, how to I synchronize so that the text in the box matches the selectedvalue in the list?