Hi:
I am binding a DataTable to an ultracombo. My combo dropdown style is DropDownList, AutoEdit = False, CauseValidation = false. The combo shows the right rows, selection works, everything works except typing a character that is not part of the combo list (e.g. my rows are temp1, and temp2 and I am typing "m"). OnValueChanged kicks in and I am getting the followiing exception: System.ArgumentException occurred Message="Object of type 'System.DBNull' cannot be converted to type 'System.Int32'." Source="mscorlib" StackTrace: at System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr) InnerException:
What I want to do is to be able to type something that is not in the list and in "Validated" add the row to my table, refresh the control and show it in the combo and keeping/showing the row as selected. The binding for the combo is done in the code not in the designer and looks like this:
TemplateCombo.ValueMember = Model.ImportTemplateDataSource.Columns["import_template_key"].ColumnName; TemplateCombo.DisplayMember = Model.ImportTemplateDataSource.Columns["description"].ColumnName;
ImportTemplateDataSource is defined as a DataTable property that set/gets a table.
So any typing in the combo outside a match gets me the exception ablove. I beleive it has to do with the entry not having a key (PrimaryKey) yet or something like that. Is this due to the binding to the table or is some setting that I don't ahve right?
Thanks,
Mihail
Add tomy question another one. I tired to delete records from the DataTable that is the source of the combo. After delete I am refreshing the DataSource (DataSource = null, DataSource = MyTable). I get the result (one record minus) but for whatever reason my dropdonwn list is getting shrinked to the length of the text isntead of the length of the combo. Not exactly why this is happening.