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.