Page 1 of 1

Programatically Accessing Subreports

Posted: Wed Aug 29, 2007 9:32 am
by raja
Hi,
I am tryign to access all subreports that are part of the main report. But it is always giving me there are no subreports. I tried to test this with the sample subreport that is part of the demo (SideBySideListWithSubReports.mrt)..

Here is the code

Code: Select all


StiReport stiReport1 = new StiReport();
stiReport1.Load("SideBySideListWithSubReports.mrt");

foreach (StiReport report in stiReport1.SubReports) {
    //do something for each report..
}

It loads the report properly but it never gets to for loop. Am i missing something here..

Thanks in advance
-Raja

Programatically Accessing Subreports

Posted: Wed Aug 29, 2007 10:27 am
by Guest
For work with subreports of the report you must have access to subreports by using components of the report:

Code: Select all

foreach (StiComponent component in stiReport1.Pages[0].GetComponents())
 {
      if (component is StiSubReport)
      {
          StiSubReport subreport = (component as StiSubReport);
           //do something for subreport...
      }    
}
Thank you.

Programatically Accessing Subreports

Posted: Wed Aug 29, 2007 10:40 am
by raja
Pavel wrote:For work with subreports of the report you must have access to subreports by using components of the report:

Code: Select all

foreach (StiComponent component in stiReport1.Pages[0].GetComponents())
 {
      if (component is StiSubReport)
      {
          StiSubReport subreport = (component as StiSubReport);
           //do something for subreport...
      }    
}
Thank you.
Thank you.. I will try using GetComponents.