Bind dataset data into combobox problem

kekewong

Member
Joined
Mar 9, 2009
Messages
7
Programming Experience
Beginner
Hi, there are a strange problem i am facing.

Ok, i have a combobox and i bind the datasource with a particular dataset.
It can bind, the data shown is correct in the combobox. But i try to use the data display in the combox and it always give me a NULL value.

For example, i try to get the data shown in the combobox .

VB.NET:
Dim strString As String
strString = Combobox1.SelectedItem.ToString

the value of strString is always NULL, but i got select the data in the combobox.

Can explain why this is hapenning?
 
Bind the data:

combo.DataSource = A_DATATABLE
combo.DisplayMember = "COLUMN_NAME_TO_SHOW"
combo.ValueMember = "COLUMN_NAME_TO_USE"

now use combo.SelectedValue to retrieve the selected value (COLUMN_TO_USE)


combo.DataSource = salutations
combo.DisplayMember = "salDescription"
combo.ValueMember = "salID"

suppose datatable contains
1, Mr
2, Mrs
3, Miss

We select "Miss"
combo.SelectedValue is 3

If you want it to be "miss" then just set Valuemember = Displaymember
 

Latest posts

Back
Top