Problem in dataBinding to Comboboxes
Reply
![]() |
|
From:
![]() AlwaysLakshmi
|
| Hi, To bind a ComboBox or ListBox control - Set the DataSource property to a data source object. Possible data sources include a data table, a data view, a dataset, a data view manager, an array, or any class that implements the IList interface.
- Set the DisplayMember property to the name of a column in the data source object:
' Visual Basic Private Sub BindComboBox() ComboBox1.DataSource = DataSet1.Tables("Suppliers") ComboBox1.DisplayMember = "ProductName" End Sub Swap the statements as first the datasource method has to be set for a combo box. I think this should solve the problem. In case you are still facing the same problem check the following link: or check this code snippet: 4.8 When I try to bind two comboboxes to the same datatable, both boxes show the same values, changing one changes the other. How do I make them have distinct values | ![]() | | Make sure the two comboboxes use different BindngContext objects. | BindingContext bc = new BindingContext();
| this.comboBox1.BindingContext = bc;
| comboBox1.DataSource = _dataSet.Tables["orders"];
| comboBox1.ValueMember = "CustomerID";
| comboBox1.DisplayMember = "CustomerID";
| bc = new BindingContext();
| this.comboBox2.BindingContext = bc;
| comboBox2.DataSource = _dataSet.Tables["orders"];
| comboBox2.ValueMember = "CustomerID";
| comboBox2.DisplayMember = "CustomerID";
| HTH Regards Lakshmi | | | |
|
View other groups in this category.
![]() |
To stop getting this e-mail, or change how often it arrives, go to your E-mail Settings.
Need help? If you've forgotten your password, please go to Passport Member Services.
For other questions or feedback, go to our Contact Us page.
If you do not want to receive future e-mail from this MSN group, or if you received this message by mistake, please click the "Remove" link below. On the pre-addressed e-mail message that opens, simply click "Send". Your e-mail address will be deleted from this group's mailing list.
Remove my e-mail address from dotNET User Group Hyd.
|
|