.Net ramblings
# Wednesday, 21 December 2005
GridView Databinding error "Field or property ... not found on the selected data source"

A field or property with the name 'xyz' was not found on the selected data source

I get this error when i bind a GridView to an array of custom objects with public variables. 
The recommended pattern for designing classes is to have private variables with public properties with get/set etc, but for my current application i'm not bothering with that. Apparently because of the Reflection methods used in GridView databinding, you have to have properties to bind fields in the GridView to your object fields. 

bit of a pain.

Wednesday, 21 December 2005 15:51:28 (GMT Standard Time, UTC+00:00)  #    Comments [3]  Asp.Net

Tuesday, 21 February 2006 17:15:37 (GMT Standard Time, UTC+00:00)
Thank you! You saved me... I was about to give up and use a contrived dataset.
Wednesday, 29 August 2007 10:02:51 (GMT Daylight Time, UTC+01:00)
Tim, I've been looking for this explanation on the web for hours! Thanks for sharing it.
Jakub Roth
Tuesday, 13 September 2011 13:31:38 (GMT Daylight Time, UTC+01:00)
Perfect, thanks!
Please login with either your OpenID above, or your details below.
Home page

Comment (Some html is allowed: a@href@title, strike) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

[Captcha]Enter the code shown (prevents robots):

Live Comment Preview