Hi, I'm trying to figure out if it's possible to conditionally change the ReportSource of a Subreport in my Detail section. So, based on some value in my main datasource, I want to display a different report as the subreport.
So my thought was to wire up the ItemDataBound event of the detail section, check the value, get a reference to the subreport and set the ReportSource to the appropriate one based on the value. Like this ...
The problem is that the SubReport that I can cast to from the item.ChildElements.Find() call is a Telerik.Reporting.Processing.SubReport. That class does not allow setting the ReportSource property. But it won't let me cast to a Telerik.Report.SubReport which is what I need to set the ReportSource. So is this even possible? If not, is there another recommended approach for this type of scenario?
Thanks,
Kevin
So my thought was to wire up the ItemDataBound event of the detail section, check the value, get a reference to the subreport and set the ReportSource to the appropriate one based on the value. Like this ...
private
void
detail_ItemDataBound(
object
sender, EventArgs e)
{
var item = sender
as
ReportItemBase;
var foo = ((
string
)item.DataObject[
"Foo"
]);
var subReport = item.ChildElements.Find(
"SubReport1"
,
true
).FirstOrDefault()
as
SubReport;
if
(foo==
"Bar"
) {
var fooReport =
new
FooReport();
subReport.ReportSource = fooReport;
}
else
{
// etc...
}
}
The problem is that the SubReport that I can cast to from the item.ChildElements.Find() call is a Telerik.Reporting.Processing.SubReport. That class does not allow setting the ReportSource property. But it won't let me cast to a Telerik.Report.SubReport which is what I need to set the ReportSource. So is this even possible? If not, is there another recommended approach for this type of scenario?
Thanks,
Kevin