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

Having a problem with context when loading reports dynamically

1 Answer 84 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Joseph
Top achievements
Rank 1
Joseph asked on 26 Mar 2012, 10:39 PM
OK, the basic error message is this: An error has occurred while processing Report 'myReport': The expression contains object 'myField' that is not defined in the current context. 

I've followed the instructions here: http://www.youtube.com/watch?v=t-iA05KpDFM  for adding a partial view to MVC to allow a report viewer, and it works as long as I use a statically defined report.

However, if I go in to the OnLoad method and try to change the report to something else, it throws the above error.

Here is my sample code:

protected override void OnLoad(EventArgs e)
{
    base.OnLoad(e);
    ReportViewer1.Report = ViewBag.ReportSource;
    ReportViewer1.RefreshReport();
}

Note the use of the ViewBag to provide access to the new report. This seems to work, except that the new report isn't properly linking to its fields.

Thanks for your timely response!

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 29 Mar 2012, 02:45 PM
Hi Joseph,

As you have presumed there is a problem with the reports data binding. Thus we will need more information on the datasource component you utilize and how you set the data item's datasource property. Additionally we will appreciate if you open a support thread and send us the problematic report definition to review and debug on our end.

Kind regards,
Peter
the Telerik team
NEW in Q1'12: Telerik Report Designer (Beta) for ad-hoc report creation. Download as part of Telerik Reporting Q1 2012. For questions and feedback, use the new Telerik Report Designer Forum.
Tags
General Discussions
Asked by
Joseph
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or