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

Sub reports from collections

3 Answers 157 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mattias
Top achievements
Rank 1
Mattias asked on 10 Sep 2008, 07:23 AM
Hi,
I am trying to make a report that has a sub reports.
I have a business object Task as an IList<Task> with a collection TaskDates.

Now, I want all the TaskDates to show as a sub report of Task but I don't understand how to generate the dates.
I have tried this (don't know if it is the "best practice" way):
private void subReport1_NeedDataSource(object sender, System.EventArgs e) 
        { 
            Telerik.Reporting.Processing.SubReport subReport = (Telerik.Reporting.Processing.SubReport)sender; 
 
            Task task = (Task)(subReport.DataItem); 
 
            subReport.InnerReport.DataSource = task.TaskDates; 
        } 
This is the sub report TaskDates event but it generates:
Unable to cast object of type 'System.Data.DataRowView' to type 'PPS.DO.Task'.

Am I on the right track here or is it completely wrong! :)

OT:
When you are making sample projects of your products it would be super if you could make some of them with business objects and not only "object datasource" like examples made in design page.

3 Answers, 1 is accepted

Sort by
0
Mattias
Top achievements
Rank 1
answered on 10 Sep 2008, 12:04 PM
One solution found! :)
It works but is not optimal cause I don't like working with non type safe objects!
Is it not possible to grab my business object directly?
Telerik.Reporting.Processing.SubReport subReport = (Telerik.Reporting.Processing.SubReport)sender; 
            DataRowView rowView = (DataRowView)subReport.DataItem; 
            subReport.InnerReport.DataSource = rowView["TaskDates"]; 

0
Sean Fuhrmann
Top achievements
Rank 1
answered on 04 Dec 2008, 06:46 PM
Any response on this, I would also like to grab my business object directly...

Thanks!
0
Steve
Telerik team
answered on 05 Dec 2008, 12:48 PM
Hi Sean,

What Mattias has found as a solution is a correct one. Currently complex types (business objects) are not flattened and that is why you cannot access them directly since they are objects. You might find this forum thread helpful as well: LINQ (or Business Object Datasource).

All the best,
Steve
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
General Discussions
Asked by
Mattias
Top achievements
Rank 1
Answers by
Mattias
Top achievements
Rank 1
Sean Fuhrmann
Top achievements
Rank 1
Steve
Telerik team
Share this question
or