J
James
I am used to VB6 but need to develop something in .Net.
I need to create several bound combo-boxes which will use lookup tables to
get their values.
I created a form using the dataform wizard. As part of the setup, I
specified a new dataset, which included the data & lookup tables. I also
specified the relationships when required.
I then added a combo box control to my form, following the instructions from
dynamic help:
I set the datasource for the control to the lookup table.
I set the DisplayMember to the required text column from my lookup table.
I set the ValueMember to the required ID column from my lookup table.
Under DataBindings.SelectedValue I specified my base table, & relevant
column.
This all appears to work, however the problem appears to arise with null
values.
When the form is loaded & the data is fetched, if the source column for the
lookup is null, the combo displays the first entry in the list of the combo
control.
If I select a value, & select the update button (the form was created with
teh standard settings in the wizard), the correct value is inserted into the
underlying table. However, when I navigate to the next record, if it is
null, again the first value in the list is displayed.
Finally, if I attempt to remove a value from the form (i.e. make it null) &
then update, the update will succeed. However the combo will then update &
show the first entry in the list.
I had a look at the code executing with a watch placed on the SelectedValue
property of the combo. It is always correct until, as part of the
UpdateDataSet sub, the DataSet.Merge method is called. At this point the
first value is displayed in the combo.
Any suggestions for a solution?
Cheers,
James
I need to create several bound combo-boxes which will use lookup tables to
get their values.
I created a form using the dataform wizard. As part of the setup, I
specified a new dataset, which included the data & lookup tables. I also
specified the relationships when required.
I then added a combo box control to my form, following the instructions from
dynamic help:
I set the datasource for the control to the lookup table.
I set the DisplayMember to the required text column from my lookup table.
I set the ValueMember to the required ID column from my lookup table.
Under DataBindings.SelectedValue I specified my base table, & relevant
column.
This all appears to work, however the problem appears to arise with null
values.
When the form is loaded & the data is fetched, if the source column for the
lookup is null, the combo displays the first entry in the list of the combo
control.
If I select a value, & select the update button (the form was created with
teh standard settings in the wizard), the correct value is inserted into the
underlying table. However, when I navigate to the next record, if it is
null, again the first value in the list is displayed.
Finally, if I attempt to remove a value from the form (i.e. make it null) &
then update, the update will succeed. However the combo will then update &
show the first entry in the list.
I had a look at the code executing with a watch placed on the SelectedValue
property of the combo. It is always correct until, as part of the
UpdateDataSet sub, the DataSet.Merge method is called. At this point the
first value is displayed in the combo.
Any suggestions for a solution?
Cheers,
James