asp.net - Can you bind an object containing a Dictionary Property to a dropdownlist? -
asp.net - Can you bind an object containing a Dictionary Property to a dropdownlist? -
for example, have instance of next class declaration:
public class person { public string name = ""; public dictionary<string, string> properties = new dictionary<string, string>(); }
and have list of person wish bind asp.net drop downwards list.
list<person> people = new list<person>(); //fill list etc.. //bind drop downwards list ddlpeople.datasource = people; ddlpeople.datatextfield = "name"; ddlpeople.datatextfield = "properties['age']"; //this like!
age present. not have command of person class. know if trying achievable?
thanks!
as far know, can not that.
i guess go :
ddlpeople.items.clear(); ddlpeople.items.addrange(people.select(p => new listitem(p.name, p.properties["age"])).toarray());
but not sure point of question.
asp.net data-binding
Comments
Post a Comment