Articles in this section
Category / Section

How to Load Drillthrough Reports in a Report Viewer Application

Published:
Updated:

Drill-through actions cover the concept of calling another report within the main report by clicking on an object. This action opens a separate report known as a drill-through report.

To change the drill-through report file path in the application and set the Stream property for a drill-through report in the OnInitReportOptions method.
The following code example demonstrates how to load a drill-through in the Report Viewer on the server side.

Code Example:

public void OnInitReportOptions(ReportViewerOptions reportOption)
        {
            string basePath = _hostingEnvironment.WebRootPath;

            if (reportOption.ReportModel.IsDrillthroughReport)
            {
                FileStream inputDrillthroughStream = new FileStream(basePath + @"\Resources\" + reportOption.ReportModel.ReportPath, FileMode.Open, FileAccess.Read);
                MemoryStream DrillthroughStream = new MemoryStream();
                inputDrillthroughStream.CopyTo(DrillthroughStream);
                DrillthroughStream.Position = 0;
                inputDrillthroughStream.Close();
                reportOption.ReportModel.Stream = DrillthroughStream;
            }
            else
            {
                FileStream inputStream = new FileStream(basePath + @"\Resources\" + reportOption.ReportModel.ReportPath, FileMode.Open, FileAccess.Read);
                MemoryStream reportStream = new MemoryStream();
                inputStream.CopyTo(reportStream);
                reportStream.Position = 0;
                inputStream.Close();
                reportOption.ReportModel.Stream = reportStream;
            }
        }

For further reference, kindly refer to the attached sample application.

ASP.NET_CORE(6.0).zip
Was this article useful?
Like
Dislike
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied