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

How to get Master ObjectDatasource to Subreport

4 Answers 139 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
RJ
Top achievements
Rank 1
RJ asked on 25 Apr 2014, 07:06 PM
Hi All,
I'm new on using Telerik Reports. I'm just wondering how can I get the ObjectDatasource of my Master to my Subreport.
I have used this code from the documentation and it works fine when I use it directly to a report but when its being used to a master, cant seem to pass the datasource.

​ Dim objectDataSource As New Telerik.Reporting.ObjectDataSource()
    objectDataSource.DataSource = GetMyData() ' GetData returns a SqlDataAdapter object which has a select command with three SELECT statements.
    objectDataSource.DataMember = "Table2" ' Indicating the exact table to bind to. If the DataMember is not specified the first data table will be used.
    objectDataSource.CalculatedFields.Add(New Telerik.Reporting.CalculatedField("FullName", GetType(String), "=Fields.Name + ' ' + Fields.ProductNumber")) ' Adding a sample calculated field.

    'Creating a new report
    Dim report As New Telerik.Reporting.Report()

    ' Assigning the ObjectDataSource component to the DataSource property of the report.
    report.DataSource = objectDataSource

    ' Use the InstanceReportSource to pass the report to the viewer for displaying.
    Dim reportSource As new InstanceReportSource
    reportSource.ReportDocument = report

    ' Assigning the report to the report viewer.
    reportViewer1.ReportSource = reportSource

    ' Calling the RefreshReport method in case this is a WinForms application.
    Me.reportViewer1.RefreshReport()


Please note that using vb code, Report Q3 2013 and I wonder why Subreport.ReportSource.Datasource is not available
Any help would greatly appreciated,
Thanks in advance,
RJ

4 Answers, 1 is accepted

Sort by
0
RJ
Top achievements
Rank 1
answered on 25 Apr 2014, 09:12 PM
I have figured it out..
My next question is how to pass the my 2nd datamember to Drillthrough report? is that possible? 
I was able to set my subreport datasource from my GetMyData() dataset with my 1st datamember  from my master.
Now on my subreport I have added action

Dim reportSource As New TypeReportSource()
reportSource.TypeName = "ReportLibrary1.Report1, ReportLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"
reportSource.Parameters.Add(New Telerik.Reporting.Parameter("OrderNumber", "SO43659"))
Dim reportAction1 As New Telerik.Reporting.NavigateToReportAction()
reportAction1.ReportSource = reportSource
textBox1.Action = reportAction1

How can now set the datasource of my Report1 with the my 2nd datamember from my master?
Don't want to get the data from the database coz I already set it on the master and all I need to do is get it, but I don't know how.

Thanks in advance,
RJ
0
KS
Top achievements
Rank 1
answered on 28 Apr 2014, 08:49 AM
Hi,

Set a binding to Report1.DataSource = ReportItem.Paremt.Parent.Parent..(as many as needed)...DataObject - http://www.telerik.com/help/reporting/data-items-how-to-use-data-object.html

-KS
0
RJ
Top achievements
Rank 1
answered on 30 Apr 2014, 07:26 AM
@KS  Code: Report1.DataSource = ReportItem.Paremt.Parent.Parent is not working

ReportItem.Parent doesn't even exist on Visual Studio IntelliSense
0
KS
Top achievements
Rank 1
answered on 02 May 2014, 12:13 PM
Hi,

It must be a typo .. the key word is Parent and it gives the container element.

-KS
Tags
General Discussions
Asked by
RJ
Top achievements
Rank 1
Answers by
RJ
Top achievements
Rank 1
KS
Top achievements
Rank 1
Share this question
or