I have a gridview that is bound to the result from an nhibernate query. If the first item in the list is edited the following exception is thrown:
System.Reflection.TargetException: Object does not match target type
It appears that the problem is caused by the fact that databinding can't deal with the first item in the list being a subtype of the other items in the list.
What is a nice / correct way to solve this problem? Currently I have had to turn off nhibernates proxying.
Edit: I have another couple of solutions:
- Clone everything in the list (http://steve-fair-dev.blogspot.com/2007/08/databind-object-does-not-match-target.html) - this doesn't work for me as the object doesn't implement ICloneable
- change the order of items in the list so that the proxy isn't first (http://community.devexpress.com/forums/t/30797.aspx) - this is so hacky, I don't think I can stoop this low!
But none of these feel right though...