We use a ReportViewer control for report hosting and generation in a Windows Application.
The report is a .rdlc (several in fact with sub reports), and runs local.
I need to gain additional control over the contents in the footer which is now required to show minimal chart data, which is sensitive to the section of the report.
I understand that I cannot put a chart in the footer, that is no issue though, as I can generate the images needed for the footer up front, however I still need a way of linking the correct images into the footer.
There are some global pages, which all would contain the same footer image along with the global PageNumber. These compose the first few pages and the last couple of pages. So basically these are fine.
There are also some dynamic report sections in the middle of the report, these are a series of sub reports in a Tablix, and each of these sections, which could span multiple pages, would have a specific report footer set by the datasets row key for the current section. The Tablix passes this id Through to the SubReports as a parameter, so I had an idea that I could use a function instead of setting the parameter directly.
The idea here was to update a global variable in code which could be accessed within the footer to provide a dynamic element to any image path.
public shared dim HeaderIndex as Int32 = 0
Public Function HeaderPassThrough(ByVal index As Int32) As Int32
HeaderIndex = index
Return index
End Function
As you may already know it does not work, whenever the footer queries the value of Code.HeaderIndex it is the value of the very last section to process. So, the footer generates after the body of the report it would seem.
There is no way I can reasonably know the page numbers in advance, 1 section might flow to a single page, another 20, so any custom content I generate to go in the footer, will be generated based on that HeaderIndex, not a page number.
I then thought is there a way to get the page number into the page, as in this case an array of page number / HeaderIndex could be stored, and then referenced by the footer. But of course the global PageNumber is not available in the report body.
I would love to hear any ideas, as to how it might be possible to control footer contents dynamically based on report data.