This is a migrated thread and some comments may be shown as answers.

Set subreport parameters and bindings problem

1 Answer 109 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Marcin
Top achievements
Rank 1
Marcin asked on 18 Sep 2013, 09:17 AM
Hi, i have a problem if i want to set subreport parameters and bindings at the same time from master report. Subreport parameters i set from designer, selecting "ReportSource" and than "Edit parameters". Subreport bindings I also set from designer (Poperty path: ReportSource, Expression: = GetReportSource(Fields.NestedClass) ). GetReportSource is method in master report .cs file:

public static ReportSource GetReportSource(object dataObject)
{
      var report = new TextReport();
      report.DataSource = dataObject;
      return new InstanceReportSource { ReportDocument = report };
}

When i fire my report i get exception "An error has occurred while processing the report. Processing canceled. Check the InnerException for more information. Invalid value of report parameter 'Title'." Parameter has null value (if i set in subreport "Allow Nulls" for parameter) report is showing.

If I remove parameter, data in subreport is well binded, and report shows properly. Also if I remove bindings report is showing properly and parameter has value.

1 Answer, 1 is accepted

Sort by
0
Nasko
Telerik team
answered on 20 Sep 2013, 03:15 PM
Hello Marcin,

As the exception you are receiving states, the Title parameter of your subreport doesn't have a value. In order to set the value of the parameter for each subreport in your master report modify the GetReportSource method as in the following code:
public static ReportSource GetReportSource(object dataObject, object title)
{
   var report = new TextReport();
   report.DataSource = dataObject;
 
   InstanceReportSource instanceReportSource1 = new InstanceReportSource();
   instanceReportSource1.ReportDocument = report;
   instanceReportSource1.Parameters.Add(new Telerik.Reporting.Parameter("Title", title));
    
   return instanceReportSource1;
}
and set your binding:
Poperty path: ReportSource, Expression: = GetReportSource(Fields.NestedClass, Parameters.Title.Value)

For more information on the topic, please check the examples in the How to: Set ReportSource for SubReport help article.

 

Regards,
Nasko
Telerik

Have you tried the new visualization options in Telerik Reporting Q2 2013? You can get them from your account.

Tags
General Discussions
Asked by
Marcin
Top achievements
Rank 1
Answers by
Nasko
Telerik team
Share this question
or