logo
small logo
  • Products
  • Comprar
  • Suporte
  • Articles
  • Customer panel Suporte
    • en
    • pt
    • es
    • de
    • pl
    • JP
    • ZH
  • Home
  • /
  • Articles
  • /
  • How to hide a report page if you don't have data on it
  • Copiando as bandas e todo conteúdo de um relatório para outro

    31 de março de 2021

    Algumas vezes é necessário usar partes de um relatório em outro. Em casos simples, você

    read more
  • Como executar um aplicativo com FastReport .NET no Docker sob Linux

    17 de novembro de 2021

    Docker é uma plataforma de software para desenvolvimento rápido, testes e implantação de aplicativos. Com

    read more
  • FastReport .NET packages e .NET 5.0

    17 de dezembro de 2020

    UPD: aplica-se às versões do FastReport.net antes de 2022.2. Pacotes de licença já estão disponíveis

    read more
  • Relatórios e documentos PDF no Blazor

    5 de abril de 2021

    A Microsoft lançou recentemente uma plataforma web chamada Blazor. Este framework permite a criação de

    read more
  • Create a new report with code VB.NET

    17 de setembro de 2020

    Speaking of the .Net framework, we usually imagine the #C programming language. Simply because the

    read more

How to hide a report page if you don't have data on it

18 de junho de 2020

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:

 Create event StartPage for the Report page

1
2
3
4
5
private void Page2_StartPage(object sender, EventArgs e)
 {
 if (Data2.DataSource.RowCount == 0)
 Page2.Visible = false;
 }

 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:

Create event StartReport for the Report object

1
2
3
4
5
6
7
8
 private void _StartReport(object sender, EventArgs e)
 {
 DataSourceBase ds = Report.GetDataSource("Category");
 if (!ds.HasMoreRows)
 {
 Page2.Visible = false;
 }
 }

 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.

about product download comprar
avatar
Dmitriy Fedyashov
Technical Writer
Fast Reports Team: Dmitriy Fedyashov - Technical Writer at Fast Reports
.NET FastReport

Add comment
logo
  • 800-985-8986 (English, US)
  • +4930568373928 (German)
  • +55 19 98147-8148 (Portuguese)
  • info@fast-report.com
  • 901 N Pitt Str #325 Alexandria VA 22314
  • Comprar
  • Download
  • Documentação
  • Depoimentos
  • Como desinstalar nossos produtos
  • Ticket system
  • FAQ
  • Tutorial Video
  • Forum
  • Articles
  • Our News
  • Informação sobre nós
  • Parceiros
  • Extended licensing
  • Contatos

© 1998-2022 by Fast Reports Inc.

  • Privacidade