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

Subreport Problem in Telerik Reporting

5 Answers 198 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Shiva
Top achievements
Rank 1
Shiva asked on 16 Jul 2013, 08:41 AM
Hi Pals,

           I am getting problem with Telerik Sub report  problem in ASP.NET.
My Requirement is I need to pass the data to Main Report and Sub report From ASP.NET Webpage Code Be-hind Page.
right now I am passing the data to Main report from the code... need to pass data to sub report from the code itself.
Please help in this issue.

Thanks in advance.


5 Answers, 1 is accepted

Sort by
0
Stef
Telerik team
answered on 19 Jul 2013, 11:44 AM
Hello Shiva,

If the report definition used as sub report does not have assigned DataSource, you can use the SubReport.NeedDataSource event to pass the data, e.g.:
private void subReport1_NeedDataSource(object sender, EventArgs e)
{
    (sender as Telerik.Reporting.Processing.SubReport).InnerReport.DataSource = objectDataSource2 ;
}

Other approach is to find the SubReport item in the report instance, get the underlying report definition through the SubReport.ReportSource, then set its DataSource property. For example:
var myReport = new Report1();
(((myReport.Items.Find("subReport1", true)[0] as Telerik.Reporting.SubReport).ReportSource
                                              as InstanceReportSource).ReportDocument
                                              as Telerik.Reporting.Report).DataSource = GetNewData();
 
reportViewer1.ReportSource = new InstanceReportSource() { ReportDocument = myReport };

I hope this helps.

Regards,
Stef
Telerik

Have you tried the new visualization options in Telerik Reporting Q2 2013? You can get them from your account.

0
Shiva
Top achievements
Rank 1
answered on 22 Jul 2013, 05:46 AM
Dear Stef,

        Thanks For your Reply...

actually My Requirement is.. I created two reports called MainReport.cs and SubReport.cs and I added Object Datasources Respectively.. MainRptObjectSource and SubRptObjectSource... for there Object Datasources I assigned two tables from the Typed Data set I created..


I need assign the Datasource of MainRptObjectSource and SubRptObjectSource. From the Code.. Means From Report.aspx.cs file.. here I am getting the data into tables Main Datatable and Sub Datatble based mu rules of filtering.. I need to assign these tables to Mainreport and Subreport object Datasources.
0
Stef
Telerik team
answered on 25 Jul 2013, 11:18 AM
Hello Shiva,

In such scenario use the second suggestion, where once the report is instantiated you can set its DataSource property. Then you can find the SubReport item in the report instance, retrieve the underlying report definition from the used report source object, and finally set the sub report DataSource property:
var myReport = new Report1();
(((myReport.Items.Find("subReport1", true)[0] as Telerik.Reporting.SubReport).ReportSource
                                              as InstanceReportSource).ReportDocument
                                              as Telerik.Reporting.Report).DataSource = GetNewData();
  
reportViewer1.ReportSource = new InstanceReportSource() { ReportDocument = myReport };

I hope this helps.

Regards,
Stef
Telerik

Have you tried the new visualization options in Telerik Reporting Q2 2013? You can get them from your account.

0
Shiva
Top achievements
Rank 1
answered on 25 Jul 2013, 11:34 AM
Dear Stef..


       Thanks For your Reply... My Problem is solved with your solution..

I have another problem... I placed a list control on report.. and placed the Table inside the List Control.. for both datasource is same.. I added grouping for List... based Group key need to load the records in Table.. how can I filter this.. help me in this.

Thanks in advance..

If possible please provide your Email ID
0
Accepted
Stef
Telerik team
answered on 30 Jul 2013, 02:49 PM
Hello Shiva,

Since the data is the same, try to add the grouping to the Table item directly. On your scenario, you can bind the Table.DataSource property to the ReportItem.DataObject. Both suggestions are illustrated in the attached sample project.

In future please avoid posting questions not related to the main topic of the thread. Feel free to open your own threads or contact us through the support ticketing system.

Let us know if you have further questions on the matter.

Regards,
Stef
Telerik

Have you tried the new visualization options in Telerik Reporting Q2 2013? You can get them from your account.

Tags
General Discussions
Asked by
Shiva
Top achievements
Rank 1
Answers by
Stef
Telerik team
Shiva
Top achievements
Rank 1
Share this question
or