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

adding a sub report dynamically

3 Answers 101 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Elliott
Top achievements
Rank 2
Elliott asked on 20 May 2013, 08:10 PM
I have a page that produces a number of reports by booths (for a trade show)
a few booths (10 out of 200) need a subreport to be added
I tried adding the subreport when the reports are built - the control is added but the report itself does not appear
I moved my logic to the ItemDataBound event of the report selected and nothing appears
what am I doing wrong?
Private Sub VRSummaryStore_ItemDataBound(sender As Object, e As EventArgs)
    Dim srPowerBoys As SubReport
    Dim thisReport As InstanceReportSource
    Dim myFoot As Telerik.Reporting.ReportFooterSection
    Dim X_Unit, Y_Unit As Telerik.Reporting.Drawing.Unit
    Dim APoint, UPoint As Telerik.Reporting.Drawing.PointU
    Dim subReport As Reports.VRPowerBuys
    Dim dsSubReport As DataSet
    Dim BoothNumber As Integer
 
    myFoot = Me.ReportFooterSection1
    APoint = Me.srActualTotals.Location
 
    srPowerBoys = New SubReport
    srPowerBoys.Style.BackgroundColor = System.Drawing.Color.Chartreuse
    myFoot.Items.Add(srPowerBoys)
    srPowerBoys.Left = Me.srActualTotals.Left
    srPowerBoys.Top = APoint.Y + Me.srActualTotals.Height
    srPowerBoys.Size = Me.srActualTotals.Size
    thisReport = New InstanceReportSource
    subReport = New Reports.VRPowerBoys
    thisReport.ReportDocument = subReport
    BoothNumber = Me.Report.ReportParameters(0).Value
    dsSubReport = DataManager.GetDataSP("rpt_store_powerboys_show", BoothNumber.ToString)
    subReport.DataSource = dsSubReport
End Sub

3 Answers, 1 is accepted

Sort by
0
Gimmik
Top achievements
Rank 1
answered on 22 May 2013, 04:34 PM
Hi Marianne,

I just went through this same process a short time back.

ItemDatabound is too late in the life cycle to add a new sub-report. Try moving your logic to the ItemDatabinding event.

Let me know if this works for you. You'll also have to configure the connectionstring for the sub-report - but it looks like you're doing that in-code too.
0
Elliott
Top achievements
Rank 2
answered on 22 May 2013, 05:55 PM
changed the location of the code - but still no subreport
it's dropping in the subreport control but not building the report that goes in it
it is also building the dataset

should I be creating a new report instance - or is there an existing report instance I should be attaching the code to?
0
Elliott
Top achievements
Rank 2
answered on 22 May 2013, 06:17 PM
my problem?
missing one line
srPowerBuys.ReportSource=subReport
Tags
General Discussions
Asked by
Elliott
Top achievements
Rank 2
Answers by
Gimmik
Top achievements
Rank 1
Elliott
Top achievements
Rank 2
Share this question
or