Hello code masters,
Today I have been banging my head in the wall trying to figure this one out.
I have a combo box filled with values from table A field A
no issue on that, I am able to populate by filling my dataset with sql query and etc.
Now the problem is, this combo box should also change selected value based on another combo box coming from a different table, table B WHILE RETAINING THE VALUES FROM TABLE A just in case they wanted to change the selected value from table A to values from table B.
I have this code which selects data OnIndexChange of combo box from tableA where value = cmb1.value
On indexchange cmb1 =
Dim ds As DataSet = SQL.RecOnChange(ojConn, BG) - select Field1 from tableA where field1 = cmb1.value
ojConn.Close()
If ds.Tables(0).Rows.Count > 0 Then
Dim DT As New DataTable()
DT = ds.Tables(0)
cmb2.DataSource = DT
cmb2.DisplayMember = "Field1"
cmb2.ValueMember = "Field1"
and this for populating the cmb2 with values on page load:
Dim ds As DataSet = SQL.PopcmbEquip(ojConn, BG) - sql statement : select field2 from tableB order by field 2
ojConn.Close()
If ds.Tables(0).Rows.Count > 0 Then
Dim DT As New DataTable()
DT = ds.Tables(0)
cmb2.DataSource = DT
cmb2.DisplayMember = "Field2"
cmb2.ValueMember = "Field2"
I am getting error:
Cannot bind to the new value member. Parameter name: value
I think the error is because I cannot assign two datasource and valuemember to one combo box :(
Any inputs will be greatly appreciated.
Thank you so much in advance.