There is a RadGrid, which is used to show and edit XML-data in a grid form. And the same XML-data can be edited manually.
There is a ComboBox on the RadGrid’s edit template. It is used to select a value from dictionary (a database table of key –value pairs ).
ComboBox is bound to a field in the grid’s datasource:
<telerik:RadComboBox ID="ddProductName" runat="server" DataSourceID="dsProducts" DataTextField="Name" DataValueField="ProductID" SelectedValue='<%# Eval("ProductID") %>' />
The problem is, that since grid’s underlying XML is manually editable, Eval() function may return invalid key values. That is, a value that is not present in the dictionary table. In such cases, the above binding to SelectedValue attribute fails, and the whole page crashes.
What do I do to overcome this problem?