do rdlc sub-reports work with mvc?

Trying to get an rdlc sub report to work in my mvc4 project.  Reports work fine, subreport works fine if run as a report; when i embed it into another report and try to run it as a subreport, it fails w/o error, i.e. report executes w/o error but no sub
report appears.  it appears the problem is that SubreportProcessing() never gets called, which is what i’ve noticed when i step through the code.

           string subPath = Server.MapPath("~/Views/Reports/" + psubrptRdlc);
            Stream subStream = System.IO.File.Open(subPath, FileMode.Open, FileAccess.Read, FileShare.Read);
            subStream = RdlcReportHelper.TranslateReport(subStream);
            localReport.LoadSubreportDefinition(subPath, subStream);
            localReport.SubreportProcessing += new SubreportProcessingEventHandler(SubreportProcessing);

Has anyone gotten an rdlc subreport to work w Mvc?

Problem is not in the mvc because MVC just host the report and not process the report. Check your embedded report through report designer to validate if it is working fine or not. May be you have not linked the sub-report with main report.

The embedded report runs fine if i run it by itself.  when i debug the code, i noticed that SubreportProcessing(), which sets the subreport’s data, never gets called inspite of this line:

localReport.SubreportProcessing += new SubreportProcessingEventHandler(SubreportProcessing);

        public void SubreportProcessing(object sender,SubreportProcessingEventArgs e)
        {
            ReportDataSource rds1 = new ReportDataSource();
            rds1.Name = "DataSet1_dtCusInterest";
            rds1.Value = FetchData();
            e.DataSources.Add(rds1);
        }

I take it from a lack of response that subreports do not work with mvc.  It’s a shame microsoft is letting (has let) RDLC Reports fall by the way side.  It filled an important role for .net developers…just one more reason to jump off the asp.net bandwagon

Hi alex_brambil…,

Thanks for your post.

Please check this:

Using Crystal Report in ASP.net MVC and creating generic report viewer

https://code.msdn.microsoft.com/Using-Crystal-Report-in-bb0e6229#content

Maybe it will help you.

Best Regards,

Eileen

Leave a Reply