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

Duplicate Subreports

5 Answers 59 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Dave
Top achievements
Rank 1
Dave asked on 06 Dec 2010, 02:42 AM
Hello,
I am dynamically adding sub reports to my detail section. Here is my code

Private Sub MasterReport_ItemDataBinding(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.ItemDataBinding
 
 
Dim unitX As Drawing.Unit = Drawing.Unit.Inch(0)
Dim unitY As Drawing.Unit = Drawing.Unit.Inch(0)
Dim size As New Drawing.SizeU(Drawing.Unit.Inch(0.01), Drawing.Unit.Inch(0.01))
Dim ds As DataSet = TryCast(Me.DataSource, DataSet)
Dim index As Integer = 0
 
Me.DetailSection1.Items.Clear()
 
For Each dr As DataRow In ds.Tables(0).Rows
  Dim d As New MyData() 'internal object that executes spocs
  Dim subReport As New Telerik.Reporting.SubReport
  Dim rpt As New NameOfSubReport
 
  subReport.ReportSource = rpt
 
  d.StoredProc = "StoredProcedureName"
  d.Parameters.Add("@PersonID", SqlDbType.Int).Value = dr("PersonID")
  subReport.ReportSource.DataSource = d.ExecuteStoredProcToDataset
 
  subReport.Location = New Drawing.PointU(unitX, unitY)
  subReport.Size = size
   
  Me.DetailSection1.Items.Add(subReport)
 
  unitY = unitY.Add(Drawing.Unit.Inch(0.1))
Next
 
End Sub

For an example we have 2 records in me.datasource. I have verified within the databound event that only 2 subreports are in the detail section. But When I set a break point in the sub report I see it is executed 4 times. If there are 3 records it is executed 6 times etc. I have tried adding to the footer section but got the same result. 

It is important to note that my sub report has 9 sub reports in it. From what I have read online, I assume this is ok

Let me know if I am doing something wrong.
Thanks
Dave B

5 Answers, 1 is accepted

Sort by
0
Dave
Top achievements
Rank 1
answered on 06 Dec 2010, 03:14 PM
After researching this further it looks like the sub report is getting executed twice. So if I set a variable in the sub report I see the value set the second time around. 

Why would a sub report be processed twice?
0
Michael Salzlechner
Top achievements
Rank 1
answered on 06 Dec 2010, 03:38 PM
is your keep together set to true on the subreport ? wonder if it has to do with prerendering of some sorts ?

0
Dave
Top achievements
Rank 1
answered on 06 Dec 2010, 04:17 PM
I think you are on to something, but I set keeptogether = false and I get the same result. I just cant debug this further because its all external code. It might be support ticket time...
0
Dave
Top achievements
Rank 1
answered on 08 Dec 2010, 03:22 PM
I was hoping to hear back from someone at Telerik,
Is there more info I should provide? More code? Anything???
0
Peter
Telerik team
answered on 08 Dec 2010, 06:21 PM
Hi Dave,

Do you use out-of-process Session by any chance and where exactly you set a breakpoint. If you are using out-of-process Session, then you have to follow the rules from the Design Considerations for Out-Proc Session KB article. In general, the report is recreated by using its default constructor and this causes the constructor being called twice. If you need further assistance we will highly appreciate if you elaborate further and send us a sample runnable project that exhibits the issue so we will be able to debug it locally.

Best wishes,
Peter
the Telerik team
Get started with Telerik Reporting with numerous videos and detailed documentation.
Tags
General Discussions
Asked by
Dave
Top achievements
Rank 1
Answers by
Dave
Top achievements
Rank 1
Michael Salzlechner
Top achievements
Rank 1
Peter
Telerik team
Share this question
or