By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,369 Members | 1,240 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,369 IT Pros & Developers. It's quick & easy.

Bound Combo Box, Lookup Table?

P: n/a
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
Nov 20 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a
I have now replicated this with from the Combo box demonstration on msdn
(http://msdn.microsoft.com/library/en...lkcreatinglook
uptableondata-boundwindowsform.asp?frame=true&_r=1)
The file can be found here:
http://www.j.goodman.dsl.pipex.com/f...bleExample.zip

This example also requires the Northwind sample db. If you set the value of
CustomerID to Null for a record, & then load the form it demonstrates this
phenomenon. If the modified record is loaded first, the combo will be blank.
However, if the user navigates to the next (or previous) record, & then back
to the record, the combo will show the first entry in the list.

"James" <j_*********@yahoo.co.uk> wrote in message
news:82************************@posting.google.com ...
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

Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.