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

How to pass a parameter to a report with a subreport that uses object data source

1 Answer 483 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jonathan
Top achievements
Rank 1
Jonathan asked on 03 Jun 2008, 05:10 AM
Hi,

I'd like to load the object data source based on a parameter rather than a hardcoded datasource as in your example or be able to run the report off a dynamically created set of objects that is pased into the report.

Your example code for a master detail report using objects looks like this:

public

RptOrders()

{

/// <summary>

/// Required for telerik Reporting designer support

/// </summary>

InitializeComponent();

//

// TODO: Add any constructor code after InitializeComponent call

//

this.DataSource = Middle.Order.CreateOrderList();

}

private void subReport1_NeedDataSource(object sender, System.EventArgs e)

{

Telerik.Reporting.Processing.

SubReport subReport = (Telerik.Reporting.Processing.SubReport)sender;

subReport.InnerReport.DataSource = ((System.Data.

DataRowView)subReport.DataItem)["OrderLines"];

}


How can I asign a dynamically created set of objects to the datasource?  Could I pass a list of objects into another constructor for the report? as in:

public RptOrders(List<RptOrder> rptOrders)

{

/// <summary>

/// Required for telerik Reporting designer support

/// </summary>

InitializeComponent();

//

// TODO: Add any constructor code after InitializeComponent call

//

this.DataSource = rptOrders;

}

 
I'm using q1 2008 reporting in a web project.

1 Answer, 1 is accepted

Sort by
0
Accepted
Milen | Product Manager @DX
Telerik team
answered on 03 Jun 2008, 10:43 AM
Hi Jonathan,

Yes, absolutely, you have the full freedom to pass the data source of the master report in a constructor, or set the public property DataSource of the report before previewing or exporting it.

When you are dynamically passing data to the detail report, you should use the NeedDataSource event of the SubReport item. In it you can use your business objects to retrieve data, and set this data as DataSource of the Processing instance of the report used as a subreport, as shown in the examples.

Find another helpful example in this forum post.

Let us know if you experience any further difficulties.

Best wishes,
Milen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
General Discussions
Asked by
Jonathan
Top achievements
Rank 1
Answers by
Milen | Product Manager @DX
Telerik team
Share this question
or