Welcome to MSDN Blogs Sign in | Join | Help

Resolving subreport errors and using nested objects (ReportViewer control in local mode)

Special thanks to Ramzi Abu Abed from Microsoft (ramziabu@microsoft.com) for the tips in this article! There are 2 parts to this post.

Part 1: Error: Subreport cannot be found

If you are trying to use subreports with a ReportViewer control in local mode, and you get “Error: Subreport cannot be found”, verify that the name of the new ReportDataSource that you add at SubReportProcessing matches the name that is generated by the ReportDesigner for the SubReport. In the following example, the value “MyCompany_CustomerService” must be copied verbatim into the Report Data Sources field of the Report Data Sources dialog box. For example, given the following code:

void LocalReport_SubreportProcessing(object sender, Microsoft.Reporting.WinForms.SubreportProcessingEventArgs e)

        {

            // Use author ID from event args to get project           

            ServiceRequest currentRequest = this.request[count];

            e.DataSources.Add(new ReportDataSource("MyCompany_CustomerService", currentRequest.RequestType));

               // e.DataSources.Add(new ReportDataSource("", currentRequest.RequestType));

           

            count++;

        }

The Report Data Sources dialog box (which appears on the Report menu when you are designing a report in Visual Studio) must have the following value:

Part 2: Using Nested Objects

If you are creating a subreport that uses nested objects, remember that you cannot drag and drop nested objects onto the report. You must manually enter an expression to access the values of second level properties. When you enter an expression, the Expression Editor will not display a drop-down value. In fact, it will flag a valid value as an error:

 

In the above example, Certificate.Value.Id is a valid value. Because it is a second level property, it does not show up in the dropdown list. Per Ramzi:  It’s intuitive to get to the fields for the Current object but to get the fields of the object within the object…there are no dropdowns that show up after “.Value” as you can see from the first figure….So it’s not intuitive for someone to know that they can use the field. For more information about using nested objects and to view an example, see http://www.gotreportviewer.com/objectdatasources/index.html

Published Wednesday, February 14, 2007 10:51 PM by rosettaue

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

No Comments

Leave a Comment

(required) 
required 
(required) 
 
Page view tracker