dukeofawesome
Member
Hi Everyone,
I am trying to get the value from a combo selection, more specifically, the DisplayMember. I have a combo box that is populated using the following code:
The combo box gets populated and lists all the relevant data. I can obtain the the selected value like so:
and it returns the correct ID. But when I try and retrieve the Display Member like so:
It just returns the field name rather than the data. I've also tried:
And it still doesn't work. What am I missing?
Thanks
I am trying to get the value from a combo selection, more specifically, the DisplayMember. I have a combo box that is populated using the following code:
VB.NET:
Sub PopComboBox(objCombo As ComboBox, strSQL As String, ValMember As String, DispMember As String)
dbs.ConnectDB()
ds = dbs.sqlSelect(strSQL)
objCombo.DisplayMember = DispMember
objCombo.ValueMember = ValMember
objCombo.DataSource = ds.Tables("Results")
objCombo.Refresh()
dbs.CloseDB()
End Sub
The combo box gets populated and lists all the relevant data. I can obtain the the selected value like so:
VB.NET:
lblDatabaseID.Text = cmbDataConnection.SelectedValue.ToString
and it returns the correct ID. But when I try and retrieve the Display Member like so:
VB.NET:
lblPath.Text = cmbDataConnection.DisplayMember.ToString
It just returns the field name rather than the data. I've also tried:
VB.NET:
lblPath.Text = cmbDataConnection.SelectedItem.ToString
lblPath.Text = cmbDataConnection.SelectedText.ToString
And it still doesn't work. What am I missing?
Thanks