Question

Out of the box SSRS reports cannot have data exposed in the page header. Is there a way to get this data to show?

Was it helpful?

Solution

One of the things I want in my reports is to have nice headers for my reports. I like to have a logo and the user's report parameters along with other data to show to give more information for the business needs the report needs to clarify. One of the things that Microsoft SQL Server 2005 Reporting Services cannot do natively is show data from a Dataset in the header. This post will explain how to work around this and how easy it is.

Create the Report Server Project in the Business Intelligence Projects section and call it AdventureWorksLTReports. I use the AdventureWorksLT sample database from CodePlex.

alt text http://www.cloudsocket.com/images/image-thumb.png

Next show the Page Header by right clicking in the Report area with the designer.

alt text http://www.cloudsocket.com/images/image-thumb1.png

The Page Header will appear. If you want to show the Page Footer this can be accessed from the same menu as the Page Header.

alt text http://www.cloudsocket.com/images/image-thumb2.png

I created a stored procedure that returns data for the Sales Order to be presented in the Page Header. I will show the following information about the Sales Order in the Page Header:

  • Order Date
  • Sales Order Number
  • Company
  • Sales Person
  • Total Due

I create a TextBox for each of my data fields in the Page Header along with a TextBox for the corresponding label. Do not change the Expression in the TextBoxes that you want the Sales Order data in.

alt text http://www.cloudsocket.com/images/image-thumb3.png

In the Report Body, place a TextBox for each data field needed in the Page Header. In the Visibility for each TextBox, select True for Hidden. This will be the placeholder for the data needed in the Page Header.

alt text http://www.cloudsocket.com/images/image-thumb4.png

Your report should look similar to the screenshot shown below.

alt text http://www.cloudsocket.com/images/image-thumb5.png

The last step and most important is to reference the Hidden TextBox in the TextBoxes located in the Page Header. We use the the following Expression to reference the needed TextBoxes:

=ReportItems!.Value

Your report should now look similar to the following:

alt text http://www.cloudsocket.com/images/image-thumb6.png

Your Report preview should now have the Sales Order Header data in the Report Header.

alt text http://www.cloudsocket.com/images/image-thumb7.png

OTHER TIPS

You have to do it through Parameters. Add a parameter for each piece of data you would like to display, then set the parameter to Hidden. Then set the default value to "From Query" and set the Dataset and Value field to the appropriate values.

I think the best option is creating a internal parameter, with the default value the field of the dataset you want to show.

Here are two possible workarounds:

  1. You can place the databound field within the body of the report as a hidden textbox, and then in the header place another textbox with it's value pointed at the the one hidden within the body.

  2. Try using report parameters to store the data, and use those parameters to access the data in the header.

This technique wouldn't work if your report spans over multiple pages, use queried parameters instead, and set the textbox value to =Parameters!Name.Value as per this article.

I'm with Orion Adrian here. Report parameters are the way to go.

I wanted to show a field, common to all returned rows, in the header, and for this scenario I went for the linked table solution (placing a table containing the field in the body and link a textbox in the header to this table).

I did that because if you are using the parameter solution and no data is returned to the field in question, the text "Parameter is missing a value" is shown instead of just a blank table. I reckoned this text would confuse users (as the parameter isn't even visible).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top