This is a migrated thread and some comments may be shown as answers.

How to determine if a report is empty

2 Answers 286 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Stefan
Top achievements
Rank 1
Stefan asked on 14 Mar 2013, 09:30 AM
I am creating bulk reports by generating reports programatically and then directly saving them to files on disk without opening.

I would like to skip saving reports which have no data in them but I need a way to check if the report is empty.

What property in the Telerik.Reporting.Report object should I check in order to do this?

The .Items property seems to include column headings so its of no use to me. I found the .Bindings collection and thought about .Bindings.Any() but I cannot find any documentation on it so I am not sure if that is an adequate solution.

2 Answers, 1 is accepted

Sort by
0
Accepted
Peter
Telerik team
answered on 15 Mar 2013, 12:20 PM
Hello Stefan,

In the report definition such property is not available. However you can easily extend it as shown in the following code snippet:

class MyReport : Telerik.Reporting.Report
{
public bool HaveData { get; private set; }
 
void textBox1_ItemDataBound(object sender, System.EventArgs e)
{
   this.HaveData = true;
}
}

The idea is that the textBox will be databound only if data is available.

Greetings,
Peter
the Telerik team

Telerik Reporting Q1 2013 available for download with impressive new visualizations. Download today from your account.

0
Stefan
Top achievements
Rank 1
answered on 18 Mar 2013, 08:28 AM
Thanks this worked.

To anyone reading this, I ended up adding my event to the ItemDataBound of the "detail" section of the report rather than a specific textbox in order to make it a little more generic.
Tags
General Discussions
Asked by
Stefan
Top achievements
Rank 1
Answers by
Peter
Telerik team
Stefan
Top achievements
Rank 1
Share this question
or