I am working in Visual Studio with WinForms. I do the databinding with the combo box in the following way.
cboCurrentSaison.DisplayMember = "Code";
cboCurrentSaison.ValueMember = "ElementID";
cboCurrentSaison.DataSource = eleSaiCur.Elements;
When I perform data entry and save in the database it works fine. In the following function I try to show the information of a product recovered from the database in the following way:
private void ProductTotext(clsScenario Sce)
{
int var = Sce.CurrentSaison();
lblInfo.Text = var.ToString();
txtCode.Text = Convert.ToString(Sce.ScenarioCode);
txtCreatedD.Text = Convert.ToString(Sce.CreatedDate);
txtCreatedU.Text = Convert.ToString(Sce.CreatedByUserID);
txtDesc.Text = Convert.ToString(Sce.ScenarioDesc);
txtModifiedD.Text = Convert.ToString(Sce.ModifiedDate);
txtModifiedU.Text = Convert.ToString(Sce.ModifiedByUserID);
cboStatus.SelectedIndex = Sce.ScenarioStatus;
cboCurrentSaison.SelectedValue = Sce.CurrentSaison();
cboPreviousSaison.SelectedValue = Sce.PreviousSaison();
}
The Sce.CurrentSaison () and Sce.PreviousSaison () methods retrieve the value (int type) that corresponds to the valuemember in order to display the displaymember in the combobox. This attempt does not work, any ideas?