hdaccess 0 Newbie Poster

I am currently making a subreport and I found it very tricky to do. I already created a parameter(ID) that would link Report2 to Main Report but still it doesn't work. I have two datasources: LoanerDataSet for the main report and LoansDataSet for report 2. I would like to ask for a step by step procedures of accomplishing this. Currently, I am encountering this error: Subreport could not be shown. Any help is much appreciated. tnx

Dani AI

Generated

For : "Subreport could not be shown" almost always means the subreport never gets the dataset it expects at runtime or the parameter/dataset names don’t match exactly. For RDLC (LocalReport) subreports you must (a) map the parameter in the main report and (b) supply the subreport’s DataSource in the LocalReport.SubreportProcessing event. If either is missing or the names differ, the subreport will fail.

A minimal checklist to follow:

  1. In the subreport RDLC define a Report Parameter named ID and add the dataset you used when designing the subreport. Note the dataset name shown in the Report Data pane (use that exact string).
  2. In the main report add a Subreport control, set its report to your subreport, then open Subreport Properties → Parameters and map the subreport ID to Fields!ID.Value (or the main-report field that links records).
  3. In the ASP.NET page code bind the main report dataset, attach the LocalReport.SubreportProcessing handler before calling RefreshReport().
  4. In the SubreportProcessing handler read the incoming parameter, load/filter the Loans rows for that ID, and add the subreport data source using the RDLC’s dataset name.

Example SubreportProcessing handler (VB.NET):

Private Sub LocalReport_SubreportProcessing(sender As Object, e As Microsoft.Reporting.WinForms.SubreportProcessingEventArgs)
    Dim idValue As String = e.Parameters("ID").Values(0)
    Dim dtLoans As DataTable = GetLoansForId(idValue) ' your method to return filtered rows
    e.DataSources.Add(New Microsoft.Reporting.WinForms.ReportDataSource("LoansDataSet", dtLoans))
End Sub

Troubleshooting tips: the ReportDataSource name must match the subreport RDLC dataset name exactly; register the event handler before RefreshReport(); wrap the handler in try/catch and log exceptions to Debug/Trace; preview the subreport alone with sample data if possible. If using server (SSRS) mode instead of LocalReport, ensure the subreport is deployed and accessible on the report server.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.