Search code examples
asp.netreportviewerreport-viewer2010reportviewer2008

c# asp.net report and sub report in report viewer (or reportviewer)


I did all the steps from this waltrought:

http://blogs.msdn.com/b/sqlforum/archive/2011/01/03/walkthrough-add-a-subreport-in-local-report-in-reportviewer.aspx

and when i run it i get the first father report and instead the sub report i get:

Data retrieval failed for the subreport, 'Subreport5', located at: C:...

i attach a print screen file (the subreport error)

i am using VS2010 framework 3.5.


Solution

  • Can you run the subreport by itself, given the right parameters? If you can't, your problem is that.

    If you can run it successfully by itself, double-check that you are passing the parameters correctly to your subreport. Make sure the parameter types match and that you are passing all of them.

    Another problem might be that -- if I recall correctly -- when you have a subreport in a local report, you need to provide the data for the subreport programmatically, just as you do with the parent report. There's an event that's raised - SubreportProcessingEvent -- when the subreport is being processed. You write a handler for that event and supply data in the handler. Here's some more information about it: LocalReport.SubReportProcessingEvent. There's a good example on that page.