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

When i call subreport with programmatically, it has error "object reference not set for subreport" on the first text box that contain field.

1 Answer 31 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Santichai
Top achievements
Rank 1
Santichai asked on 29 Sep 2016, 10:28 AM
IDE : Visual Studio 2015
Reporting Version : Q2 2016 (10.1.16.615)
Host: IISExpress

I create DummyMain report that must be call DummySubreport with programmatically.
When i run the report on first time after start solution, the TextBox with expression Fields.Id has error "object reference not set for subreport" on the first page but other page has not error.

Please, see the error image and report in the attachment file. 

link:https://drive.google.com/file/d/0B9yIfZcD3RmJX2dGR3RoOHo2ajg/view?usp=sharing 

Let me know what needs to be fix?  Thanks.

1 Answer, 1 is accepted

Sort by
0
Katia
Telerik team
answered on 03 Oct 2016, 02:11 PM
Hello Santichai,

Inside the event handler, you need to use the processing element instead of the report's private field, for example:
void report_NeedDataSource(object sender, EventArgs e)
{
            List<TestItem> items = new List<TestItem>();
            items.Add(new TestItem() { Id = 1, Name = "Person 1" });
            items.Add(new TestItem() { Id = 2, Name = "Person 2" });
            items.Add(new TestItem() { Id = 3, Name = "Person 3" });
             
            Telerik.Reporting.Processing.Report processingReport = (Telerik.Reporting.Processing.Report)sender;
            processingReport.DataSource = items;
}

You can check Understanding Events help article for more detailed information.


Regards,
Katia
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
Santichai
Top achievements
Rank 1
Answers by
Katia
Telerik team
Share this question
or