I am new here. And have a big issue which I will really appreciate if you could help with.
Im developing a software which is just entering some data to the access file and retrieve it after some filtering (done by using date time pickers, radio buttons, combo boxes…etc)
When I want to update any entry I simply write a select query and add those values to relevant fields. But thing is that I cannot update my combo boxes. I got 2 of them. When I try following code it throws errors.
What can I do? pls help me out. Thanks!
cmb_district.ValueMember = dt1.Rows[0][1].ToString();
I use the data source property to connect combo box with access database. It clearly has display and value members. But When query returns the value it do not update the combo box and give following error.
Cannot bind to the new value member.
Parameter name: value
Thanks. Pls help me out!
The code line you provided is incorrect.
ValueMemberof the combo box should be set to the name of the property or column that you want to be the value of your selected object (unique ID for example). But you are filling theValueMemberwith the content of a field.When you bind the combo box in this way (setting the datasource with combination of
DisplayMemberandValueMember), theSelectedValueproperty of the combo box is filled with the value ofValueMemberfield of the selected row.For example suppose that you have a DataTable with columns ActorID, Name and BirthDate with some data in it:
When we read the
SelectedValueof the combo box, it gets us the “ActorID” of the selected row.