all groups > visual studio .net general > february 2006 >
You're in the

visual studio .net general

group:

ComboBox


ComboBox Lee
2/19/2006 1:40:30 PM
visual studio .net general:
I am using VB.NET 2005 and a ComboBox that has a datatable as its data
source. I have the DisplayMember and ValueMember properties set to the
appropriate columns in the dataset. When a selection is made in the ComboBox,
the SelectedValue returned does not match the value from the data table.
What's going on here? I have verified via xml dump on the data table that the
data in the table is correct etc.
Re: ComboBox pvdg42
2/19/2006 5:42:16 PM

[quoted text, click to view]
Which were you expecting to be returned in SelectedValue, the DisplayMember
or the ValueMember? You'll get the ValueMember. Are you saying that
SelectedValue is returning values don't coincide with the DisplayMember
shown when you look at the datarow in question?

Re: ComboBox Lee
2/20/2006 5:56:32 AM
The selected value should return the valuemember but it is not returning the
correct value. The value returned does not correspond to the value on the
Re: ComboBox Lee
2/20/2006 8:01:29 AM
the value type is an integer, nothign special. I'll have to try to break this
down later. I have worked around the problem by creating a class that has and
Id and Text fields and fill the ComboBox with those instead and it works. So
Re: ComboBox pvdg42
2/20/2006 9:53:05 AM

[quoted text, click to view]

I'm afraid you've got me stumped, then. I cannot reproduce your problem
here, using tables from various databases such as pubs and Northwind.
A stab in the dark...
What datatype is the value member you are working with?

AddThis Social Bookmark Button