Link to home
Start Free TrialLog in
Avatar of karakav
karakav

asked on

Reporting Services: How to know if the report is empty

I am working on a web application which shows reports builts from Reporting Services. To show the report on the page I use a Report Viewer. I would like to know if there is a way to check whether the report has data before showing up the report.
Avatar of jgv
jgv

There's no method you can use through SSRS to check for this condition. You would have to independently run the same query that the report uses to see if there are any records. If you are asking because you want to show an appropriate message to the user in this situation there is a property for this. If you are using a List or Table object, look for the "NoRows" property. You can fill in a message that you want displayed on the report when no data is returned (ie: "No data was found matching your input")
Avatar of karakav

ASKER

What do you mean by "Using a List or Table"? Because me I directly show the report in a Report Viewer control.
To set the NoRows property you have to edit the report in the report designer. This property should be available on the main object used to show the data (a Table, List, Matrix, etc). Did you build the report yourself or is this a report someone else built?
Avatar of karakav

ASKER

I did it myself. The problem is that I don't manage to format that message so that I resemble the messages shown in the application.
I'm not really sure what you mean by that last comment. Does the NoRows message shown in the report have to match something that is shown in your application (ie: the message can change each time the report is run?)

If you want to be able to set the NoRows message from your application you could create a "dummy" parameter that is set to Hidden and allows blank values. Pass a message into this parameter that will be shown if there is no data. The expression for the NoRows property would be something like this:
=Parameters!MessageToShowIfNoData.Value
Avatar of karakav

ASKER

My concern about the format is: For instance in the whole application, if a gridview doesn't contains data, I show a label with no data message. That label has same format: read font with special character. My problem is that inside the report designer, I can only define the no data message, but I can't define how that message will look like.
ASKER CERTIFIED SOLUTION
Avatar of jgv
jgv

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of karakav

ASKER

And what do I do mi mu current table header?
You can have more than 1 table header. Right click the table header row and select "Insert Row Above"
Avatar of karakav

ASKER

Yeah, I saw. The problem is that my columns are dynamic and I don't in advance which columns will be displayed.
Your choices are pretty limited. You could place another table on the report just above your existing table. Only include the table header row with the message but set the Hidden property on the table itself.
Avatar of karakav

ASKER

OK. I will try it. Thanks very much for you help. It was very much appreciated.