I have several combo boxes that are databound and populated from a list.
Both controls are populated from the same table and structure:
var status = new AgencyDetail().GetAgencyStatus(); foreach (var item in status) { StatusComboBox.Items.Add(item.Value, item.Label); } // Producer or CSR var prodType = new AgencyDetail().GetProducerType(); foreach (var item in prodType) { ProducerTypeIdCombo.Items.Add(item.Value, item.Label); }
this is how I currently bind its value:
StatusComboBox.DataBindings.Add("Value", Producer, "Status"); ProducerTypeIdCombo.DataBindings.Add("Value", Producer, "ProducerTypeId");
Everything looks correct in the UI they have the correct display and value, which is numeric.
When changing the StatusCombo in the UI it works as expected. When I change the ProducerType it always reverts back to the original bound value.
Both list have 3 or more items. I have manually change the value in the DB and it is displayed correctly in the UI.
I have several other comboboxes that behave the same but use a different table for the data.
I don't get why one works and the others don't. I have deleted/created and copied the control with no changes.
Help!!!
First thing that comes to mind is the 'ProducerTypeId' field is readonly. If 'Producer' in this context is a DataTable, check to see if the ReadOnly property on the 'ProducerTypeId' DataColumn returns true; if so, it is probably an identity column, which cannot be modified. If 'Producer' is an object, see if the 'ProducerTypeId' property is readonly.
If you've eliminated this possibility, it would be kind of impossible for us to guess what's going on there without a sample project.
'Producer' is a datatable in a entity context. It is not a identity column and its not readonly.
The only difference is that the Status column is a string and i am saving an int, where Producertypeid is an Int32 saving an int.