I have an issue with a combo box control. Items are retrieved from the database, but it won't let me access it via SelectedValue property.
I tried setting it up like this:
DataSet ds = retrieveData(); //I am calling a procedure, it works fine
myComboBox.DataSource = ds;
myComboBox.DisplayMember = "COLUMN1";
myComboBox.ValueMember= "COLUMN2";
But it wouldn't work. The text in the combo box was
System.Data.DataViewManagerListItemTypeDescriptor
So I did this:
foreach (DataRow dr in ds.Tables[0].Rows)
{
myComboBox.Items.Add(
new { TEXT = dr["COLUMN1"].ToString(),
VALUE = Convert.ToInt32(dr["COLUMN2"].ToString())
});
}
Now it works. But I have to access the index (myComboBox.IndexOf("Text inside")) instead of the value (which is primary key, therefore guaranteed to be unique). SelectedValue is always null, and the SelectedIndex is an anonymous object which fields I can't access either!
Any help?
System.Data.DataViewManagerListItemTypeDescriptor- dzenesiz