Hi,
I am trying to set the datasource for the report using the NeedDataSource event of the report. I am able to do so as
private
void
BasicReport_NeedDataSource(
object
sender, EventArgs e)
{
Telerik.Reporting.Processing.Report mainReport = (Telerik.Reporting.Processing.Report)sender;
mainReport.DataSource =
new
List<
string
> {
"test1"
,
"test2"
,
"test3"
,
"test4"
};
//The below commented statement leave the fields blank on the report UI
//this.DataSource = new List<string> { "test1", "test2", "test3", "test4" };
var subReportOne =
new
Report1();
subReportOne.DataSource =
new
List<
string
> {
"item1One"
,
"item2One"
,
"item3One"
,
"item4One"
};
var subReportTwo =
new
Report2();
subReportTwo.DataSource =
new
List<
string
> {
"item1Two"
,
"item2Two"
,
"item3Two"
,
"item4Two"
};
var subReportItemOne =
this
.Items.Find(
this
.subReportOne.GetType(),
true
)[0]
as
Telerik.Reporting.SubReport;
subReportItemOne.ReportSource =
new
InstanceReportSource() { ReportDocument = subReportOne };
var subReportItemTwo =
this
.Items.Find(
this
.subReportTwo.GetType(),
true
)[0]
as
Telerik.Reporting.SubReport;
subReportItemTwo.ReportSource =
new
InstanceReportSource() { ReportDocument = subReportTwo };
}
As you can see above, i can set the datasource for the subreports easily by getting its object but not for the report using the "this" keyword. Please can someone explain why do I need to get it explicitly from the sender instead?
Many thanks!!