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 (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.
  2. Katia
    Admin
    Katia avatar
    299 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.


    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
  3. DevCraft banner
Back to Top