G
Guest
I have a combobox whose datasource is a lookup table populated from the
database. However, the record whose field is bound to the SelectedValue of
the combo uses DBNull to indicate no selection, in which case the combobox
should display "<default>". I convert the DBNull to zero in the source
record, and I would like this to cause the default to display in the combo.
I don't have the option of adding a value to the lookup table in the db, so
I'm inserting a row with the <default> token upon loading the lookup table,
with ID=0. I do AcceptChanges on the table after the insert.
If I bind the combobox's DataSource to this altered table, binding is broken
on the form (all bound controls are blank). If instead, I create a *new*
table, add the default token, add the rows from the database table to the new
lookup table, and then bind the combo's DataSource to the new table,
everything works fine.
Is there some trick to binding the combo's datasource to the original table
loaded from the db, after the <default> row is inserted, rather than having
to create a copy? I would have thought that the AcceptChanges() would be
enough to make the two cases indistinguishable.
database. However, the record whose field is bound to the SelectedValue of
the combo uses DBNull to indicate no selection, in which case the combobox
should display "<default>". I convert the DBNull to zero in the source
record, and I would like this to cause the default to display in the combo.
I don't have the option of adding a value to the lookup table in the db, so
I'm inserting a row with the <default> token upon loading the lookup table,
with ID=0. I do AcceptChanges on the table after the insert.
If I bind the combobox's DataSource to this altered table, binding is broken
on the form (all bound controls are blank). If instead, I create a *new*
table, add the default token, add the rows from the database table to the new
lookup table, and then bind the combo's DataSource to the new table,
everything works fine.
Is there some trick to binding the combo's datasource to the original table
loaded from the db, after the <default> row is inserted, rather than having
to create a copy? I would have thought that the AcceptChanges() would be
enough to make the two cases indistinguishable.