Using UseExternal report and GetSubReport ...

Stimulsoft Reports.NET discussion
Post Reply
gagnonp
Posts: 3
Joined: Thu Oct 11, 2007 1:41 pm
Location: canada

Using UseExternal report and GetSubReport ...

Post by gagnonp »

Hello,

I am evaluating your product for my company and so far I like what I'm seeing. However, I am trying to add a SubReport to a DataBand, with GetSubReport and UseExternalReport, as explained in this thread ( http://forum.stimulsoft.com/Default.aspx?g=posts&t=746 )

The GetSubReport event works as expected. It is fired as many times as I have rows in my DataBand. The problem is this : when I receive the event, and I check the value for the data in the dictionary, it always gives me the value from the first row of my DataSource.

I use this code inside my GetSubReport :

Code: Select all

StiReport parentReport = sender as StiReport;
StiDataSource data = parentReport.Dictionary.DataSources["MyDataSource"];
object value = data["MyColumn"];
The value of ((StiDataSource)data).Position is always 0. If I edit the Position, it gives the expected data.


My version is : Stimulsoft Reports.Net 2007.2 for .Net 2.0 Trial -- WITH this update : Stimulsoft Reports.Net 2007.10.10 D2005

Any help would be appreciated,

Thank you!



Guest
Posts: 182
Joined: Tue Jun 06, 2006 8:04 am

Using UseExternal report and GetSubReport ...

Post by Guest »

You can add a variable to dictionary, for example, "v". Then if you use data band you can write in the RenderingEvent of this band, for example:

Code: Select all

v = Products.UnitPrice
Then you can write:

Code: Select all

StiReport parentReport = sender as StiReport;
object value = parentReport["v"];
instead:

Code: Select all

StiReport parentReport = sender as StiReport;
StiDataSource data = parentReport.Dictionary.DataSources["MyDataSource"];
object value = data["MyColumn"];
Thank you.
gagnonp
Posts: 3
Joined: Thu Oct 11, 2007 1:41 pm
Location: canada

Using UseExternal report and GetSubReport ...

Post by gagnonp »

One thing I have noticed is that the subreport renders at the top of the DataBand, no matter where I place it in the design of the main report. Would I have to place it in a separate band?

I have been keeping track of the current databand by counting how many times the GetSubReport event is fired. I am trying to switch to your method now, but I can't get the rendering events to fire. Here is how I try to do it ( sorry if I'm just being bad :cry: ) :

Code: Select all

         
         StiReport stiRep = new StiReport();
         
         stiRep.Load(AppDomain.CurrentDomain.BaseDirectory + "Report.mrt");
                  
         MyDataSet myDataSet = FillMyDataSet();

         stiRep.RegData(myDataSet.MyTable);
        
         stiRep.Rendering += new EventHandler(stiRep_Rendering);

         StiDataBand dataBand = (StiDataBand)stiRep.GetComponentByName("DataMyTable");
         dataBand.Rendering += new EventHandler(dataBand_Rendering);

         stiRep.Render();
Guest
Posts: 182
Joined: Tue Jun 06, 2006 8:04 am

Using UseExternal report and GetSubReport ...

Post by Guest »

You can write code for RenderingEvent in the Designer, this is more fast and easy way, than using run-time code.

Thank you.
gagnonp
Posts: 3
Joined: Thu Oct 11, 2007 1:41 pm
Location: canada

Using UseExternal report and GetSubReport ...

Post by gagnonp »

I was planning to avoid most if not all designer code , because of the way I plan to encapsulate report making...

Anyways, I got it to work through other means, and I'm more worried about the subreport inside my databand doesn't keep the relative position that I assigned to it via the designer.

THanks.
Post Reply