This project has moved and is read-only. For the latest updates, please go here.

SubreportProcessingEvent is not firing


Hi Team,

I have wired up the SubreportProcessing event to a method where I set the data source for the sub reports. But, the event doesn't fire. Please take a look.

reportViewer.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(SubreportProcessingEvent);

Thanks in advance.

file attachments


jalexandrian wrote Mar 27, 2016 at 6:29 AM

I had this issue too. The problem is the ReportViewer gets copied to a new instance on the ASPX page. It doesn't look like this project is active anymore, so I downloaded the source and fixed it for my project. I am happy to contribute the fix to this project if the owner is willing to accept.

landlessr wrote May 24, 2016 at 8:20 PM

I would really like to be able to use it with subreports. Will you be releasing a version that allows that? jalexandrian (above) has offered to contribute the update.

andrealveslima wrote Jun 6, 2016 at 5:32 AM

Hi all,

Just to let you guys know, I also faced this issue and fixed directly in the library. Probably it is not the best way to fix it, but, what I did was that I added this code to copy the handlers for the SubreportProcessing event in the end of ReportViewerExtensions.SetProperties(this LocalReport localReport, LocalReport properties) method:
            // Copying SubreportProcessing handler.
            var fInfo = typeof(LocalReport).GetField("SubreportProcessing", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
            var sourceDelegate = fInfo.GetValue(properties) as SubreportProcessingEventHandler;
            if (sourceDelegate != null)
                SubreportProcessingEventHandler addDelegate = sourceDelegate.GetInvocationList().First() as SubreportProcessingEventHandler;
                if (addDelegate != null)
                    localReport.SubreportProcessing += addDelegate;
Ideally, the ReportViewerExtensions class should copy all event handlers from the Report Viewer control, LocalReport and ServerReport, and not only the LocalReport.SubreportProcessing. But, I had no more time to invest on a better solution.

André Lima

wrote Nov 17, 2016 at 1:32 AM

jalexandrian wrote Nov 17, 2016 at 1:32 AM

Attached is a unified diff report of the changes I did to enable subreports. The root cause of the bug is that it does not copy over your SubreportProcessing eventhandler from the source ReportViewer to the one used internally, so that event never fires. I added a method named CopyEvents to the CopyPropertiesHelper.cs file that copies over events from the source ReportViewer to the one that is used internally. Also, added code to call this new method inside ReportViewerExtensions.cs. That is all you need. Hope that helps.