2 combobox from same data source & same data table in VB.Net2005
-
hi i am facing one problem at the time of desinging 2 combobox from one datasource & one datatable. my data table contains following fields - item_code | length | rate xyz | 1000.00 | 2.0 bnm | 500.00 | 1.0 qwe | 300.00 | 0.50 i have to select rate for the selected item code & selected length. for this i am desiging two combobox separately but after selection of 2nd combo popup contents of 1st combo clearing. is there any solution using multicolumn combo or datagridview in 2005 ? if yes - how? plz. help me
Thanks bye
-
hi i am facing one problem at the time of desinging 2 combobox from one datasource & one datatable. my data table contains following fields - item_code | length | rate xyz | 1000.00 | 2.0 bnm | 500.00 | 1.0 qwe | 300.00 | 0.50 i have to select rate for the selected item code & selected length. for this i am desiging two combobox separately but after selection of 2nd combo popup contents of 1st combo clearing. is there any solution using multicolumn combo or datagridview in 2005 ? if yes - how? plz. help me
Thanks bye
Each combo requires its own separate dataview as the datasource. The two dataviews 'point' to the same table. If you don't do this then each combo is using the table's default dataview as the datasource and a selection in one combo then affects the contents of the other. -- modified at 10:26 Sunday 19th August, 2007
-
hi i am facing one problem at the time of desinging 2 combobox from one datasource & one datatable. my data table contains following fields - item_code | length | rate xyz | 1000.00 | 2.0 bnm | 500.00 | 1.0 qwe | 300.00 | 0.50 i have to select rate for the selected item code & selected length. for this i am desiging two combobox separately but after selection of 2nd combo popup contents of 1st combo clearing. is there any solution using multicolumn combo or datagridview in 2005 ? if yes - how? plz. help me
Thanks bye
Hi, Try this... Dim dvItemCode as New DataView(DataTable) Dim dvLength as New DataView(DataTable) Dim dvRate as New DataView(DataTable) ComboBox1.DataSource = dvItemCode ComboBox1.DisplayMember = "Item_Code" ComboBox1.ValueMember = "ID" ComboBox1.DataSource = dvLength ComboBox1.DisplayMember = "Length" ComboBox1.ValueMember = "ID" ... Hope this helps :)
NajiCo http://www.InsideVB.NET[^] It's nice 2b important, but it's more important 2b nice...
-
Hi, Try this... Dim dvItemCode as New DataView(DataTable) Dim dvLength as New DataView(DataTable) Dim dvRate as New DataView(DataTable) ComboBox1.DataSource = dvItemCode ComboBox1.DisplayMember = "Item_Code" ComboBox1.ValueMember = "ID" ComboBox1.DataSource = dvLength ComboBox1.DisplayMember = "Length" ComboBox1.ValueMember = "ID" ... Hope this helps :)
NajiCo http://www.InsideVB.NET[^] It's nice 2b important, but it's more important 2b nice...
hi thanks for immed. reply & sorry for late reply i have done like u said but it shows one error - Error - 'can not bind to the new display member.' ParameterName : newdisplaymember my code is as follows - con.connectionstring = con_str da_combo1.selectcommand =new sqlclient.sqlcommand da_combo1.selectcommand.connection = con str_sql = "select * from dbo.rate_mas" da_combo1.selectcommand.commandtext = str_sql da_combo1.fill(ds,"rate_mas") dim dt as datatable = new datatable("rate_mas") dim dvitemcode as new dataview(dt) dim dvlength as new dataview(dt) dim dvrate as new dataview(dt) combo1.datasource = dvitemcode combo1.displaymember = "item_desc" **** it shows the above said error for immed. following stmt combo1.valuemember = "item_code" ******** error end combo1.datasource = dvlength combo1.displaymember = "length" combo1.valuemember = "id" what can i do to solve this error bye
Thanks bye
-
Each combo requires its own separate dataview as the datasource. The two dataviews 'point' to the same table. If you don't do this then each combo is using the table's default dataview as the datasource and a selection in one combo then affects the contents of the other. -- modified at 10:26 Sunday 19th August, 2007
-
hi thanks for immed. reply & sorry for late reply i have done like u said but it shows one error - Error - 'can not bind to the new display member.' ParameterName : newdisplaymember my code is as follows - con.connectionstring = con_str da_combo1.selectcommand =new sqlclient.sqlcommand da_combo1.selectcommand.connection = con str_sql = "select * from dbo.rate_mas" da_combo1.selectcommand.commandtext = str_sql da_combo1.fill(ds,"rate_mas") dim dt as datatable = new datatable("rate_mas") dim dvitemcode as new dataview(dt) dim dvlength as new dataview(dt) dim dvrate as new dataview(dt) combo1.datasource = dvitemcode combo1.displaymember = "item_desc" **** it shows the above said error for immed. following stmt combo1.valuemember = "item_code" ******** error end combo1.datasource = dvlength combo1.displaymember = "length" combo1.valuemember = "id" what can i do to solve this error bye
Thanks bye
Hi, first please make sure that you are not trying to assign columns of two different tables to ValueMember and DisplayMember. In your case you have to check that item_desc and item_code belong to rate_mas datatable. Good luck :)
NajiCo http://www.InsideVB.NET[^] It's nice 2b important, but it's more important 2b nice...