An error has occurred while processsing Report 'Group' (my object)
An error has occurred while resolving '' data source: Object reference not set to an instance of an object.
this is my needDataSource
protected void needDataSource(object sender, EventArgs e)
Telerik.Reporting.Processing.ReportItemBase subreport = sender as Telerik.Reporting.Processing.ReportItemBase;
if (this.DataSource != null)
ods = new ObjectDataSource();
ods.DataSource = this.DataSource;
ods.DataMember = groupid;
subreport.Report.DataSource = ods;
Thanks in advance!
5 Answers, 1 is accepted
It is not good idea to set data source of other data items (be it subreport, table or chart) in the NeedDataSource of the report. If you have to do this with code a valid approach would be the NeedDataSource of the subreport item itself:
If your scenario is different, please send us a runnable example with explanations what is it you're trying to achieve and we would advise you accordingly.
the Telerik team
In the main I've set the subreport's data using the
However, I cannot see, nor access, this when stepping through the subreport's code. I want to cast the back to the data object. But, when stepping into this, the is empty. This worked before upgrading from Q42014 to the current report code, and the deprecation of the report object.
Below is a quote from my response to your inquiry in our support ticketing system:
You can set the DataSource of the processing report at run-time when the sub report requests its data (NeedDataSource event). In the sub report you will be able to access the data only through the processing report as the designed report's DataSource is not set (Me.DataSource) in order to have its NeedDataSource event fired.
You can create a user function accepting ReportItem.DataObject, where the function can be used in the sub report for getting its assigned data object.
If you need further help, please use one of both threads to share further details about the case.
Thank you for your understanding.
I simply caught the sender in the subReport, cast it to the appropriate processing object, and then used the object's .Report.DataSource to get the subreport's data.
Please check the updated Understanding Events help article to determine if this usage of events will not bring further issues.
We can also suggest you to test the data binding approaches from How to bind Sub Report to Main Report's Data and Change Sub Report based on Main Report's Data.