Search code examples
webformsreportviewerrdlcexpressionreportviewer2008

Why won't binding to a child object property with rdlc Report work in vs2010?


A while ago someone asked how to bind to a child object's property in a rdlc report. Question here.

The solution was to use an expression like this:

=Fields!ChildObject.Value.SomeProperty

I have recently tried to upgrade to version 10 of the reporting libraries (Microsoft.ReportViewer.WebForms and Microsoft.ReportViewer.Common) and for some reason this does not work anymore. I have got the report rendering and displaying all data fine except any which uses this technique. Instead of the property value i get the text: "#Error"

Why doesn't this work anymore? Anybody know how to to this in the new version?


Solution

  • I can confirm that this bug has been fixed in VS2010 SP1 ... but you have to mark all of the relevant classes as Serializable.

    You can find a sample project on this site which shows a working version: http://wraithnath.blogspot.com/2011/04/reportviewer-object-datasource-nested.html

    The author also mentions that your classes will need a parameterless constructor but I have gotten it to work with classes without the default constructor. Still, if you have marked everything as serializable and are still seeing the "#Error" message, give it a try with parameterless constructors.