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

Unable to associate Data With SubReport

2 Answers 128 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 29 Jun 2009, 06:18 PM
I have a report project which I am trying to pass a dataset with two data tables.  This is not really a master detail report, but more of a document that will be saved and printed by the application.  I have tried everyway I've seen on the forum to populate the sub report, but nothing works?  I've tried setting the data source of the Report property of my sub report, adding code to the NeedDataSource method of the sub report, adding code to NeedDataSource of the actual report that is the sub report, etc.  When I step the code, I can see that the datasource is correct when the report is created and the data set has the data, but when the report is generated in the report veiwer, its like it loses the connection with the data.  The only time something will display in the subreport is when I hard code values.  The only way to get the actual data to display is to make it a separate report.  Since I can't get the sub report concept to work, I've decided to just try to use the Report book approach since I have one report for the header, and one for the lines.  Is there any problem with using this appoach for my situation?  And do you have any ideas why setting the data source for the sub report is not working?  I'm using Q1 2009.

2 Answers, 1 is accepted

Sort by
0
Jon
Top achievements
Rank 1
answered on 01 Jul 2009, 11:34 PM
The ReportBook concept didn't work since each report book was on a separate page.  I figured out a solution that worked for me.  I created Static/Shared properties in my Report object for the Data Tables and set them after InitilizeComponent() in a custom constructor where I passed them in.  I then referenced these static properities in the NeedDataSource method of the main report, and sub reports, setting the datasource of the processing report to the appopriate DataTable, making sure to use MyBase.NeedDataSource for the sub report event handlers.

 

0
Svetoslav
Telerik team
answered on 02 Jul 2009, 05:30 PM
Hi Jon,

If I've understood you correctly, you need to create a master-detail report. Using the SubReport item is the proper way to embed one report into another. For more information please read Creating Master-Detail Reports Using SubReports. You can achieve similar results by using the Table item as well, as it has its own data source. For more information on the Table item please see Working with the Table/CrossTab/List items.
 

Sincerely yours,
Svetoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
General Discussions
Asked by
Jon
Top achievements
Rank 1
Answers by
Jon
Top achievements
Rank 1
Svetoslav
Telerik team
Share this question
or