Count datarows in subreport

Stimulsoft Reports.NET discussion
ChristianH
Posts: 43
Joined: Fri May 25, 2007 2:54 am
Location: Austria

Count datarows in subreport

Post by ChristianH »

I have a report with two subreports included.
Top position of the lower subreport2 should depend on the heigt of the upper subreport 1.

I can´t achive this by using dock property because there are texts between the subreports and this results in wrong dock order.
Counting the datarows of subreport1 (with count()) would also be a solution but how can I get datarows of subreport2 from mainreport ?
Guest
Posts: 182
Joined: Tue Jun 06, 2006 8:04 am

Count datarows in subreport

Post by Guest »

For getting amount datarows of second subreport you can use a variable. Create a new variable: CountRows(type: int, default value: 0), write in the RenderingEvent of data band in the second subreport:

Code: Select all

CountRows++
and set property "Number of Pass" of the report to "Double Pass", then you will get the number of datarows in the second subreport.

Thank you.
ChristianH
Posts: 43
Joined: Fri May 25, 2007 2:54 am
Location: Austria

Count datarows in subreport

Post by ChristianH »

Thanks for the hint.

I´ve tried your solution but now there occurs another problem:
My subreport works with a hierachical band and the output now looks like this:
. parent
. parent
. parent

instead of
. parent
. child
. child

Maybe this is a result of the double pass ?
Guest
Posts: 182
Joined: Tue Jun 06, 2006 8:04 am

Count datarows in subreport

Post by Guest »

We have tested some reports with hierachical bands concerning your problem, and couldn't reproduce behaviour:
.parent
.parent
.parent

instead of
.parent
.child
.child

Send to support@stimulsoft.com your report with few sample data. We will checkup it.

Thank you.
ChristianH
Posts: 43
Joined: Fri May 25, 2007 2:54 am
Location: Austria

Count datarows in subreport

Post by ChristianH »

Your right, your solution is working. I ´ve made some mistakes... :brick:
Thanks.
ChristianH
Posts: 43
Joined: Fri May 25, 2007 2:54 am
Location: Austria

Count datarows in subreport

Post by ChristianH »

Unfortunately there is another problem with this solution:
When I start the report the first time the rows count in subreports returns 0.
After a refresh or showing second time the result is ok.
Guest
Posts: 182
Joined: Tue Jun 06, 2006 8:04 am

Count datarows in subreport

Post by Guest »

We have tested this issue and we have always a nice result. May be, you use a report with some specific conditions?

Thank you.
ChristianH
Posts: 43
Joined: Fri May 25, 2007 2:54 am
Location: Austria

Count datarows in subreport

Post by ChristianH »

You are right !
It was again a data failure from my side as I ran the report first time with missing data..

Can you please give me an overview of the correct order of steps when processing a report ?
(1. report.load, 2. regdata, 3. synchronize ...)
Guest
Posts: 182
Joined: Tue Jun 06, 2006 8:04 am

Count datarows in subreport

Post by Guest »

You must use first

Code: Select all

report.Load()
then

Code: Select all

report.RegData()
or use this methods in reverse order, but then you must use

Code: Select all

report.Dictionary.Synhronize()
after first two methods.

Thank you.
ChristianH
Posts: 43
Joined: Fri May 25, 2007 2:54 am
Location: Austria

Count datarows in subreport

Post by ChristianH »

Regarding my original problem with counting datarows: I now have a new report structure:

I´ve got a mainpage where I a place a subreport (subreport1) ten times on one page (two columns, five rows)

Into subreport1 I´d like to place another subreport (subreport2) with the hierarchical band where I have to count datarows.
The number of datarows in subreport2 again determines the height of subreport2 in subreport1.
The problem now is, that subreport2 is called ten times (plus some more counts !?) and so the number of rows is counting up wrong.

Isn´t there an easier way to get the number of rows of the hierarchical band?
I would be happy if I just could get the number of datarows in one of my datatables.
Post Reply