RPX not showing SubReport

Posted by: roman.mueller on 10 October 2020, 1:05 am EST

  • Posted 10 October 2020, 1:05 am EST

    I have a AR14 section report MyReport. This MyReport contains a ReportHeader and Detail. Within the Detail, there is just a SubReport (MySubReport), which displays a couple of records.

    public MyReport() {
    this.Detai.Format += this.OnFormatDetail;

    private void OnFormatDetail(object sender, EventArgs e) {
    MySubReport report = new MySubReport();
    report.DataSource = this.DataSource;
    this.subReportDetail.Report = report;

    When I print the report, everything is fine.

    Now, for customization purpose, I added another label and picture in MyReport in the ReportHeader and save the report as an RPX (VisualStudio > Extensions > Report > Save Layout).

    Now, when I create the report and load the above saved RPX, the SubReport is not displayed anymore.

    MyReport report = new MyReport();
    XmlTextReader xtr = new XmlTextReader("C:\\Temp\\Report.rpx");
    report.DataSource = ...

    The DataSource is exactlly the same.

    I attached the Report, SubReport and RPX.
  • Replied 10 October 2020, 8:05 pm EST

    Ok, found the mistake, why my subreport was not run after loading the layout, although it makes not really sense to me. Instead of my original OnFormatDetail in the MyReport, I had to write...

    private void OnFormatDetail(object sender, EventArgs e) {
    MySubReport sr = new MySubReport();
    sr.DataSource = this.DataSource;
    ((SubReport)((Detail)sender).Controls[nameof(this.subReportDetail)]).Report = sr;

    Hope that helps anyone else.
  • Marked as Answer

    Replied 11 October 2020, 3:21 pm EST


    Code in .CS part does not save in the .RPX layout. Therefore, you need to rewrite it after loading the RPX format in the SectionReport object.

    Hope it clarifies.

Need extra support?

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

Learn More

Forum Channels