Hi
I'm using an Ultracombo and binding it to a table's field like Order.DestinationCountry and the Datasource is another table Country so I can show two columns for the country's Code and Name. That works fine.
But if the DestinationCountry has been deleted from the Country table then the bound value doesn't show in the ultracombo.
I can't go through all Order records to find valid and invalid destination countries, that's not efficient. Plus I want only valid Country values in the Datasource so users can't select an invalid Country.
I'm thinking I have to bind an UltraTextEditor to Order.DestinationCountry then switch to the UltraCombo so users can select only valid a country.
Or is there another solution?
Thanks
John
Hi John,
I don't see how this could possibly work. In a typical application, you would hide or disable invalid choices. If you remove the options from your database, then any old records pointing to that field will no longer be able to access the data - since it isn't there. So that doesn't really make sense.
What I would do is simply use the InitializeRow event of the combo to hide the rows on the list that are not valid. The Combo will still be able to find these items in order to match up the controls Value and show the correct display text. But the item will not appear on the list and so the user will not be able to select that item int the future.
Hi Mike
I probably didn't explain it well.
Image the combo's list is the Username field on the Employee table but I bind the combo to the Order.Operator field.
After an employee 'John Doe' leaves, his Employee record is deleted but some old Order records would still have 'John Doe' as their operator. When the combo comes across one of these, 'John Doe' isn't in its list so it shows no value.
To follow your suggestion, I'd have to populate the combo's value list by searching all Order records instead of the Employee table which has much fewer records.
No, what I am saying is that is doesn't make sense to delete the employee from the Employees table. Doing so means that you are losing data.
Typically, what you would do in a case like this is not remove the Employee from the table, but simply mark that employee as inactive. Then hide than Employee from the list so the user cannot select that Employee via the UI.
If you delete the Employee from the Employees table, then what happens when a user tries to open up an existing record where that Employee was selected as the operator? The Combo cannot know what to do in this case. It can't match up the Operator ID with an item on the list, so it will just end up showing the ID number instead of the Employee's name.
You seem to be looking for some way to simply detect this case and then show some other text. There's currently no way to do that.
An 'inactive' field would be best practice but not all of our tables have one.
Even so, this is an exceptional situation. I was wondering if there was some way to handle it.
I'm going to either show a message that the invalid bound value couldn't be shown (easier) or add/remove the invalid value into the combo's list.
Thanks for your replies