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

Display Multiple UriReportSources as one Report in WPF ReportViewer

2 Answers 321 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Thom
Top achievements
Rank 1
Thom asked on 05 Oct 2020, 08:27 AM

How can WPF ReportViewer display Multiple UriReportSources as one Report?

I want to diplay multiple UriReportSources (same trdp UriReportSource and same ParameterName, but varios ParameterValues) in WPF ReportViewer as one Report, wich contains this multiple UriReportSources successively.

Here is my C# Code:

ReportBook RB = new ReportBook();

UriReportSource uriRS = new UriReportSource();
uriRS.Uri = "MyYearTest.trdp";
uriRS.Parameters.Add(new Telerik.Reporting.Parameter("Year", 2018));

RB.ReportSources.Add(uriRS)

UriReportSource uriRS = new UriReportSource();
uriRS.Uri = "MyYearTest.trdp";
uriRS.Parameters.Add(new Telerik.Reporting.Parameter("Year", 2019));

RB.ReportSources.Add(uriRS)

UriReportSource uriRS = new UriReportSource();
uriRS.Uri = "MyYearTest.trdp";
uriRS.Parameters.Add(new Telerik.Reporting.Parameter("Year", 2020));
RB.ReportSources.Add(uriRS)

InstanceReportSource IRS = new InstanceReportSource();
IRS.ReportDocument = RB;
this.TRPViewer.ReportSource = IRS;

Both Objects (RB and IRS) contains 3 ReportSources.
But the WPF ReportViewer (this.TRPViewer) shows 3 times the same page, in fact 3 times the first Report of the Year 2018!

How can i display all 3 Years Reports (2018,2019,2020) as one Report in WPF ReportViewer?

2 Answers, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 08 Oct 2020, 06:19 AM

Hi Thom,

You need to set the Report Parameter Mergeable property to False. Its default value is True. Then, you may pass values to all parameters in the main InstanceReportSource passed to the viewer by specifying the report index along with the parameter name, for example:

ReportBook RB = new ReportBook();

// Set Mergeable property of parameter "Year" for "MyYearTest.trdp" to False
UriReportSource uriRS0 = new UriReportSource();
uriRS0.Uri = "MyYearTest.trdp";

// This is reports(0)
RB.ReportSources.Add(uriRS0)

UriReportSource uriRS1 = new UriReportSource();
uriRS1.Uri = "MyYearTest.trdp";

// This is reports(1)
RB.ReportSources.Add(uriRS1)

UriReportSource uriRS2 = new UriReportSource();
uriRS2.Uri = "MyYearTest.trdp";

// This is reports(2)
RB.ReportSources.Add(uriRS2)

InstanceReportSource IRS = new InstanceReportSource();
IRS.ReportDocument = RB;
IRS.Parameters.Add("reports(0).Year", 2018);
IRS.Parameters.Add("reports(1).Year", 2019);
IRS.Parameters.Add("reports(2).Year", 2020);

this.TRPViewer.ReportSource = IRS;
More details can be found in the Report Book Parameters article.

Regards,
Todor
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Thom
Top achievements
Rank 1
answered on 08 Oct 2020, 01:39 PM

Hi Todor,

thank you very much for your answer, that helped me.

Thom

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