I cannot create a class or my own object so I thought I would use a List<KeyValuePair>
to store two properties and then bind this object to a combobox.
However, I cannot see how I can set the valueField
and TextField
in the combobox.
The code.
List<KeyValuePair<int, string>> kvpObject =
new List<KeyValuePair<int, string>>();
foreach (User u in m_users) {
kvpObject.Add(new KeyValuePair<int, string>(u.ID, u.Name));
}
// Bind Add Users combobox
cmboBox.DataSource = kvpObject;
cmboBox.ValueField = "????" // Maybe something like kvpObject[0]..
cmboBox.TextField = "????";
cmboBox.DataBind();
Does anyone know what I need to put inside the ????
.