Link to home
Start Free TrialLog in
Avatar of ndornack
ndornack

asked on

c# winform combo box does not display database value

I have a 2 combo boxes on my form.

cboCurPartNum
Data Source  - curpartBindingSource
Display Member - PartNum
Value Member - Part Num
Selected Value - engordbindingsource - curpartnum

cboPrePartNum
Data Source  - prepartBindingSource
Display Member - PartNum
Value Member - Part Num
Selected Value - engordbindingsource - prepartnum

When the form is loaded a object "engord" contains all the data for the selected engineering order and this gets binded to "engordbindingsource".  the fields engord.curpartnum and engord.prepartnum populate
cbocurpartnum and cboprepartnum, respectively.

for some reason only the cbocurpartnum is working.

cboprepartnum does not work - it will not select the value from engordbindingsource - prepartnum

What am I missing?
Avatar of ndornack
ndornack

ASKER

I have inserted a breakpoint and see the SelectedItem property is coming back with null.  Any idea why SelectedItem would be coming back at null?
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes, prepartBindingSource is filled with values.  If I set the SelectedText property, the value from engordBindingSource.prepartnum is displayed.  However, when you select the dropdown and value is not selected on in the list, which is coming from prepartBindingSource.
I had to trim the data before assigning to the combo box.  Now its working.  Thanks for your comment.