views:

201

answers:

2

Hi,

I have a report created in SSRS in client mode, which is run disconnected: I create the data source in code and pass to the report as a DataView. It works ok.

But I need to be able to reference from the project to some objects (variables, whatever) from my application, as follows:

  1. I need some totals that are not calculated based on data in report. e.g. the reports show total sales in a period, with own total, but I need to display a field in report footer - previous month total (actually they are about 10 other "previous" totals).

  2. I need to have some columns show / hide based on some settings in the application (e.g. I have application option : Show Previous month sales)

Any thoughts on how to do this?

Thank you

+1  A: 

For question 1 - the data - the easiest approach would be to create a DataTable in memory and add it as another dataset OR to add fields for your original dataview that contain these values.

Question 2 - To hide or show the columns based on settings make the column visibility an expression based on the value of a parameter, in your code behind set the parameter value to your application setting.

keithwarren7
Thanks for answer. The second question is actually an example of usage for what I need to access application objects in report.I used already the first suggestion (adding extra fields to the view) but I thought maybe there's a better or more straight-forward approach
bzamfir
+1  A: 

Q1-> In order to use data in your reports, you need to specify the data inside of a Datasource object. You cannot simply use the variables if that is what your intentions were. So yes, you are doing this the right way. * Sorry, you could theoretically used Report Parameters for this.

Q2-> This is the real reason to use Report Parameters. You can pass parameters to the report to do exactly this. If the HideColumn parameter (for example) is set to true, you could hide all the columns that need to be hidden.

http://msdn.microsoft.com/en-us/library/ms251750%28VS.80%29.aspx

Jon
Thanks for answer.Is there any way to use parameters of custom object types, instead of simple types?
bzamfir
Not that I know of, no.
Jon