Subreport in script for page aspx

Posted by: luca on 17 July 2023, 9:27 pm EST

    • Post Options:
    • Link

    Posted 17 July 2023, 9:27 pm EST - Updated 18 July 2023, 12:51 am EST

    i’m starting to use active Report in page aspx.

    I create in my load the report by :

    Dim rpt As GrapeCity.ActiveReports.SectionReport = New GrapeCity.ActiveReports.SectionReport()

    Dim xtr As System.Xml.XmlTextReader = New System.Xml.XmlTextReader(Server.MapPath(“~\Reports\Example.rpx”))

    rpt.LoadLayout(xtr)

    xtr.Close()

    And now i’d like load also the subreport by script in my report.

    I try something as :

    Dim MySu As GrapeCity.ActiveReports.SectionReportModel.SubReport = me.Mysubreport

    Dim Filename as string = Server.MapPath(“~\Reports\Rpt_subreport.rpx”)

    MySu.LoadLayout(Filename)

    MySu.DataSource = _ds.tables(“table_data”)

    CType(rpt.Sections("PageFooter1").Controls("Sub_report"), SubReport).Report = MySu
    

    but script don’t accept server.

    After i try to set filename nmanually btt i have proble with command LoadLayout.

    Is correct ‘load’ the subreport in the script in this way ?

    Where can i find some example about this for aspx ?

  • Posted 19 July 2023, 3:01 pm EST - Updated 19 July 2023, 3:23 pm EST

    Hey,

    To assign a subreport to your parent report you need to assign the ‘SectionReport’ object of the report you want to use as the subreport, please refer to the code snippet below:

            Dim xtr As New System.Xml.XmlTextReader(Server.MapPath("~") + "\RpxReports\Example.rpx")
            _rpt.LoadLayout(xtr)
            xtr.Close()
    
            Dim xtr1 As New System.Xml.XmlTextReader(Server.MapPath("~") + "\RpxReports\SubReport.rpx")
            _subRpt.LoadLayout(xtr1)
            xtr1.Close()
    
            CType(_rpt.Sections("Detail").Controls("SubReport1"), SubReport).Report = _subRpt  
    

    Please find attached a sample implementing the same.

    Regards,

    Anand

    WebViewer_ASP.NET_VB.NET.zip

  • Posted 19 July 2023, 7:01 pm EST - Updated 19 July 2023, 7:18 pm EST

    I have an error on code :

    Dim xtr As New System.Xml.XmlTextReader(Server.MapPath(“~”) + “\RpxReports\Example.rpx”)

    The error is : ‘Server’ not declared. It may be inaccessible due to its protection level.

    I had this code in scripf of report.

    I moved it in load of page and it works.

    Thank you.

  • Posted 20 July 2023, 1:23 am EST

    Another question , also connected to this problem.

    I use vb.net , is it possible in the script of a report use function of application ?

    I image to use something like :

    imports Myfunction

    and after use the function in it .

    So it doesnt works :frowning:

  • Posted 20 July 2023, 9:29 pm EST

    Hey,

    In order to access a code of your project in the .RPX script you’ll first need to Load your .RPX report into SectionReport class, after which handle the ReportStart event in your project’s code (.cs/.vb) file to add your class using ‘SectionReport.AddNamedItem(“myItem”, new clsMyItem());’ after which you can access your function within .RPX Scripting Section.

    Please find attached a sample implementing the same for your reference.

    P.S.: To learn about loading your .RPX report into Section Report Class please refer to Save and Load RPX Report Files.

    To learn more about giving script access to functions in a class in your project please refer to Add Code to Layouts Using Script.

    Regards,

    Anand

    UseCodeInScript.zip

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels