Data sources do not always contain data. And when you build reports, even if the data source is empty, the page will be created, at least with headlines.
On report generator forums, you can find questions from users about how to hide blank pages:
"Please tell me how to skip (not print) a blank page if DataBand on it contains no data."
For example, the report generator Stimulsoft Reports developers propose to hide the page by using the tool Conditions. Setting a condition to check the number of records in the source, you can specify the page display component option. A good solution, simple enough.
The topic of the article is relevant to any report generator, so let's look at the way to do this in FastReport.NET
Data Bend has PrintIfDatasourceEmpty property which is false by default. This means that the band will not be displayed if the data is not there. But still the page is displayed to the user as it contains the data headers, or page title. Therefore, we need to write a simple script that will hide the page, if the band with this empty.
There are two options:
1) Check the void data source in the band with the data. To do this, use the StartPage event page of the report:
But in this case, you need to enable the DoublePass option for the report. The fact is that we can check the void of the band with data only at the stage of page formation, and we need to hide it. The DoublePass option includes a double pass when building a report. During the second pass, it will already be known that the data source in the band is empty and the page will be hidden before it is built.
2) The second method does not require a round trip of the report. We just need to add a handler for the event StartReport report object:
In this case we check directly to the data source of the report, table Category. And then we can find out whether the source is empty before the start of the report creation page.
Thus, we have considered a way to hide the page when there is no data in the source.