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

2 posts, 0 answers
  1. Santichai
    Santichai avatar
    1 posts
    Member since:
    May 2015

    Posted 29 Sep Link to this post

    IDE : Visual Studio 2015
    Reporting Version : Q2 2016 (
    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. 


    Let me know what needs to be fix?  Thanks.
  2. Katia
    Katia avatar
    241 posts

    Posted 03 Oct Link to this post

    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.

    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
  3. DevCraft R3 2016 release webinar banner
Back to Top