We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Add Subreport with Stream

Hi,
I'm trying to add a Subreport dynamically via a Stream.

I've tryed to call the method LoadSubreport directly after the LoadReport Method.
But it's not working. Every time I get this error message: "An error occurred while rendering 'SubReport' report item."

If I render the SubReport as a normal report it works.

In the path-field of the subreport control I've set the same text i pass through the LoadSubReport method


What am I doing wrong?
Can you please provide me with an example project?

Thx


5 Replies

MM Mageshyadav M Syncfusion Team February 25, 2019 05:21 AM

Hi Stefan, 
 
We have validated the mention query with your shared details at our end. Please find the following code snippet to load subreport from stream, 
 
private void MainWindow_Loaded(object sender, RoutedEventArgs e) 
{ 
    viewer.ProcessingMode = ProcessingMode.Local; 
    Assembly assembly = typeof(MainWindow).GetTypeInfo().Assembly; 
    Stream reportStream = assembly.GetManifestResourceStream("ReportViewer.Reports.MainReport.rdlc"); 
    Stream subReportStream = assembly.GetManifestResourceStream("ReportViewer.Reports.SubReport.rdlc"); 
    viewer.SubreportProcessing += Viewer_SubreportProcessing; 
    viewer.LoadSubreport("SubReport", subReportStream); 
    viewer.LoadReport(reportStream); 
    viewer.DataSources.Clear(); 
    viewer.DataSources.Add(new Syncfusion.Windows.Reports.ReportDataSource("TopSalesPerson", SalesPersons.GetTopSalesPerson()));    
    viewer.RefreshReport(); 
} 
private void Viewer_SubreportProcessing(object sender, Syncfusion.Windows.Reports.SubreportProcessingEventArgs e) 
{ 
    e.DataSources.Clear(); 
    e.DataSources.Add(new Syncfusion.Windows.Reports.ReportDataSource("StoreSales", StoreSales.GetData())); 
} 
 
We have created standalone sample to load subreport from the stream and it can be downloaded from the following location,    
 
Regards, 
Mageshyadav.M 



IM Imperator February 25, 2019 01:04 PM

Hi,

Thanks a lot.



MM Mageshyadav M Syncfusion Team February 26, 2019 07:29 AM

Hi Stefan, 
  
Thanks for your update. 
  
We hope provided solution would have helped on your side. 
  
Regards, 
Mageshyadav.M 



IM Imperator February 26, 2019 12:47 PM

Hi again,
yeah thank you very much.

It helped a lot.


PR Padmini Ramamurthy Syncfusion Team February 27, 2019 12:56 AM

Hi Stefan, 
  
You are welcome and please get back to us at anytime if you need any other assistance. 
  
Regards, 
Padmini 


Loader.
Live Chat Icon For mobile
Up arrow icon