Reputation: 1389
In RDLC reports, we are planing to use a sub report as the report header to avoid code duplication and to keep the consistency across all the reports.
However RDLC does not allow to add sub reports in the header section. Hence we can only add it to the body. When adding to the body, sub report is only visible in the first page. We need to display it as the header in all the pages.
Does anyone has come across a scenario like this and have an idea to achieve this?
Thanks, Wijitha
Upvotes: 2
Views: 2787
Reputation: 23
you may also do like this :
ReportViewer header_report = new ReportViewer();
header_report.LocalReport.ReportPath=PATH_TO_HEADER_REPORT
byte[] IMAGE_CONTAINER = rp.LocalReport.Render("Image", "<DeviceInfo><OutputFormat>JPEG</OutputFormat><DpiX>1000</DpiX><DpiY>1000</DpiY></DeviceInfo>");
// THEN ADD TO THE MAIN REPORT DATASOURCES
main_reportviewer.LocalReport.DataSources.Add(new ReportDataSource("DataSet2", new List<CUSTOM_OBJECT>() { A_BYTE[]_FIELD=IMAGE_CONTAINER }));
This should do the trick.
NB : Think of setting the image properties properly so that the rendered image doesn't overflow the box. Also, in the header report make sure to set the report width/height the same as the width/height of the body
Upvotes: 0
Reputation: 1291
You may need to re-think your approach. If you want for ALL reports to have the same header, why don't you use your "header" report as a "main" report and drop other reports into it's body as sub-reports?
Also, you may choose to use Table in the main report and create your "header" in Table header and set it to repeat on each page and add your sub-reports as detail rows. It depends on the logic of your report(s) and if you need any additional grouping or visibility conditions.
Upvotes: 2