In my database I have a table Cars which contains (among other things) an idCategory column which is a foreign key. That foreign key refers idCategory in the Category table which contains the description of the category.
Now in my C# application I got a form that is used to add new cars. There is a combobox to choose the category.
comboboxCat.DataSource = datatable1;
comboboxCat.DisplayMember = "categoryDescription";
comboboxCat.ValueMember = "idCategory";
So I set the DataSource of the ComboBox to the DataTable that contains the data of Category table, and I set the id as the valueMember and the Description as DisplayMember.
I also have a DataSet containing the table Cars. What I want to do is to automatically update the Car data in the DataSet when the value of the Combobox is changed. I don't know how to bind it. In a datagridview it's easy because I just have to set the DataPropertyName of the DataGridViewComboBoxColumn. But there's not such properties in a normal ComboBox. Thanks in advance
I belive you have to bind the IdCategory field from the Cars DataTable to the SelectedValue of the ComboBox.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With