I’ve seen lots of posts about binding a dictionary to a drop down when the value is a string.
What if the value is a class with a particular property of that class being the one thats displayed in the drop down?
Dictionary<Int32, MyClass>
// Value
class MyClass {
public String Yer="123";
public String Ner="321";
}
How do I display property Yer in my dropdown that’s bound to that dictionary?
You need to use the
DataTextFieldandDataValueFieldproperties to the combo. Try this:The overridden ToString on MyDummyObject is just to prove that it isn’t being called (which is the default action if you don’t specify
DataTextFieldorDataValueField).