views:

2631

answers:

2

I already searched for this and I did not find the answer I was looking for.

I am writing a windows forms program with C# .NET and Visual Studio 2008. I am using Reporting Services and rendering the reports using the .net provided report viewer. The data source for the reports is SQL Server. I am rendering the reports locally. I am not using a report server. The reports are .rdlc files.

I would like to programmatically add a page footer to the report (not a table footer) based on input from the user in a form. I do know how to pass parameters to a report from a windows form. I don't know how to use this technique or another technique to dynamically create or remove a footer. When the footer is created on the fly I need to add text.

Currently I have a permanent footer with text boxes that I populate by passing parameters to the report viewer.

List<ReportParameter> parameters = new List<ReportParameter>();

parameters.Add(new ReportParameter("FootnoteLine1", FootnoteLine1.ToString()));

parameters.Add(new ReportParameter("FootnoteLine2", FootnoteLine2.ToString()));

reportViewer1.LocalReport.SetParameters(parameters);

Any help is appreciated.

+1  A: 

You are going to have to learn to use VB.NET in order to use the Custom Code feature of Reporting Services. Another option is to write an expression that returns false when the user does not enter a valid parameter, and a true when the user has entered a valid parameter. This expression should be set for the "Hide/Show" field of the footer. This field should be found in the footer or text box "Properties" dialogue.

l3a0
A: 

The only way I was able to achieve the level of flexibility I wanted at runtime was to write code to build the .rdlc file from scratch. The rdlc files are just XML, which means the .net xml classes can be used to generate the file. If the user does not want a footer, then the program simply does not write that part of the xml file.

MSDN even has a tutorial on how to do this.

http://msdn.microsoft.com/en-us/library/ms170239.aspx
JK