I have to be able to load the type from an object[] then find the property requested to be returned.
Sounds simple, and I can do it if I explictly cast the object but I need this to be dynamic as the items in the object[] could be of one type in one control but different in the next.
I am probably missing something but I keep getting this Error
"Object does not match target type."
Expand|Select|Wrap|Line Numbers
- Type dataItem = Parent.DataItems[0].GetType();
- PropertyInfo[] props = dataItem.GetProperties();
- PropertyInfo dn = dataItem.GetProperty("DisplayName");
- object myValue = dn.GetValue(dataItem, null); //<!--- this is the problem;
Everything I have tried has failed, I see the property in the PropertyInfo[] and I can return the Property I just cannot get the value to return (its a string value in this case)
Any help would be great!
Thanks,
R. Kozar