I have 2 comboboxes, each connected to the same DataTable as follows:
channelTypeCB.DataSource = SynergyData.ds.Tables["ChannelTypes"];
channelTypeCB.DisplayMember = "channelType";
channelTypeCB.ValueMember = "channelTypeID";
channelTypeCB.BindingContext = new BindingContext();
newSKChanTypeCB.DataSource = SynergyData.ds.Tables["ChannelTypes"];
newSKChanTypeCB.DisplayMember = "channelType";
newSKChanTypeCB.ValueMember = "channelTypeID";
newSKChanTypeCB.BindingContext = new BindingContext();
When I click the button to insert the record into the database, I use channelType.SelectedValue ... which returns the wrong value. I have a feeling that this is due to the use of the ComboBox class (which I set in the properties of the control in the design view). Has anyone encountered this problem?
This is programmed for a winforms application using C #
Edit:
For example, my Datatable stores values, for example:
channelType channelTypeID
Web 2
Mailer 3
Catalog 4
This is sorted in a combobox, and when I select the first item (which will be “Catalog” when sorting), SelectedValue returns 2, when I select the second item, it returns 3 .... I would expect “Catalog” to return 4