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

Subreport within databound table needs value

3 Answers 157 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Steve Healey
Top achievements
Rank 1
Steve Healey asked on 11 Jan 2012, 01:10 PM
I have a table which is bound to a dataset using the NeedDataSource event.  Within the table layout I have a SubReport which requires a value to be passed to it (SignItemId) which is taken from the data.

I have worked through all the binding events for the table and for the SubReport but try as I might I am unable to find a way to pass this value to the SubReport.

This is what I am trying at the moment in the SubReport ItemDataBinding event.  It dosent matter where I place the code the DataObject is always returned as nothing.
Dim subReport As Telerik.Reporting.Processing.SubReport = TryCast(sender, Telerik.Reporting.Processing.SubReport)
 
        Dim processingTable As Telerik.Reporting.Processing.Table = TryCast(subReport.Parent, Telerik.Reporting.Processing.Table)
 
        Dim dataRow As System.Data.DataRowView = TryCast(processingTable.DataObject, System.Data.DataRowView)
        If dataRow IsNot Nothing Then
            MastDetails1.SignId = CInt((dataRow("SignItemId")))
        End If

3 Answers, 1 is accepted

Sort by
0
Elian
Telerik team
answered on 12 Jan 2012, 05:42 PM
Hello,

There's no need for you to do this in code. You can easily do this in the designer. Look at the Passing Parameters section of this article.
Note: First you should have the sub-report created and assigned.

Greetings,
Elian
the Telerik team

Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

0
Steve Healey
Top achievements
Rank 1
answered on 13 Jan 2012, 01:49 PM
Thanks for the reply.

The SubReport is defined with a single parameter, I have added it to a field within a table on the main report and assigned a parameter to it with the value as suggested above however it still returned a value of 'nothing'

The value is assigned at design time and read in code at runtime within the NeedDataSource event.

I cant see what I am doing wrong. I have confirmed that value in the parent report.
Private Sub MastDetails_NeedDataSource(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.NeedDataSource
 
    '// Use the value passed by the parameter from the parent report
    Dim l_ds As DataSet = Common.Db.ExecuteDataSet("spQuote_Masts_SelectBySignId", Me.ReportParameters("SignItemId").Value)
 
    ' // Take the Telerik.Reporting.Processing.Report instance  
    Dim report As Telerik.Reporting.Processing.Report = CType(sender, Telerik.Reporting.Processing.Report)
 
    report.DataSource = l_ds
 
End Sub

0
Elian
Telerik team
answered on 16 Jan 2012, 04:24 PM
Hi,

This is because you are using the definition of the report.
Me.ReportParameters("SignItemId").Value  -  this will give you the default values that you assign in the designer. 
If you want to get the values you have passed from the master report, you have to use the processing object:

Dim report = TryCast(sender, Telerik.Reporting.Processing.Report)
Dim param = report.Parameters("Parameter1").Value

This information is available in the Using Report Parameters programmatically help article.

Kind regards,
Elian
the Telerik team

Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

Tags
General Discussions
Asked by
Steve Healey
Top achievements
Rank 1
Answers by
Elian
Telerik team
Steve Healey
Top achievements
Rank 1
Share this question
or