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

SubReport Visibility

7 Answers 301 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
heba
Top achievements
Rank 1
heba asked on 13 Aug 2008, 11:05 AM
Hii Team ,
I have master report which pass parameter to a subreport sometimes the subreport don't have data in it
i need to make the subreport area and headers hidden when no data represented in the subreport
i tried this 

Telerik.Reporting.Processing.

SubReport subReport;

subReport = (Telerik.Reporting.Processing.

SubReport)sender;

if (subReport.InnerReport.Items.Count == 0)

subReport.Visible =

false;

but it not working i need to know what should i do to make it hidden when no data

7 Answers, 1 is accepted

Sort by
0
Chavdar
Telerik team
answered on 13 Aug 2008, 12:55 PM
Hi heba,

The easiest way to do this is shown in the following code snippet:

private void subReport1_ItemDataBound(object sender, System.EventArgs e)
{
Processing.SubReport subReport = (Processing.SubReport)sender;
Processing.Report report = (Processing.Report)subReport.InnerReport;
subReport.Visible = report.Items.Find("detail", true).Length > 0;
}

Note that your expression (subReport.InnerReport.Items.Count == 0) will always evaluate to false if you have at least one report header or report footer section. For this reason you have to check only whether you have detail sections as shown in the snippet. The "detail" parameter is the name of the detail section of the sub report. 

Hope this helps. Let me know if something is missing.

Kind regards,
Chavdar
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
heba
Top achievements
Rank 1
answered on 13 Aug 2008, 09:01 PM
i tried it but it doesn't work still the header of the subreport appears with no data
0
Chavdar
Telerik team
answered on 14 Aug 2008, 11:23 AM
Hello heba,

Please, open a support ticket and attach there the reports which cause the problem. We have to review your code in order to help you find the problem. The code snippet from below hides the entire SubReport item so there is no way for the sub report to appear partially if the code is executed correctly.

Best wishes,
Chavdar
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
heba
Top achievements
Rank 1
answered on 14 Aug 2008, 12:49 PM
Hi Team
thank you very much for your help it is working now
0
Chavdar
Telerik team
answered on 14 Aug 2008, 01:46 PM
Hello heba,

It is great to hear that. We are glad that our suggestion helped.

Greetings,
Chavdar
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
GVera
Top achievements
Rank 1
answered on 01 May 2009, 07:59 PM
I tried this solution but when I run the report it hides the sub-report no matter what the return result is.  Need help.
Thanks,

Gabe.
0
GVera
Top achievements
Rank 1
answered on 01 May 2009, 08:05 PM
I figured it out.  need to use .ChildElments instead of .Items (obsolete)
Tags
General Discussions
Asked by
heba
Top achievements
Rank 1
Answers by
Chavdar
Telerik team
heba
Top achievements
Rank 1
GVera
Top achievements
Rank 1
Share this question
or