Is there a way to bind to an ASP.NET ListControl without specifying the DataTextField and DataValueField properties? Maybe some class that will allow the ListControl to infer which property is the text and which the value?
Having to specify these properties every time has lead to typo woes in the past. I think it would help if I could just bind to a collection of the same object type every time and completely ignore the field properties.
If you do want a control like this, you could extend the
ListBoxclass to assume defaults.Use reflection on the
DataSourceandGetPropertiesof the data type assigned.Assume defaults as you like; say the first Property as key(
DataValueField) and the last as value(DataTextField).