none
Display multiple subreports RRS feed

  • Question

  • I need to be able to show multiple subreports for each main report item. Is it possible to have multiple subreports? If so, how do you handle the subreportprocessing event?
    Tuesday, May 29, 2007 6:01 PM

All replies

  • Yes it is possible to have multiple sub reports, I currently am working with a Main report with 10 sub reports.

     

    The subreportprocessing event will be called each time the reportViewer comes across a subreport in the rdlc file. what you need to do at this point is to assign the DataSources for the subReport, e.g.

     

    e.DataSources.Add(Report_Data_Source);

     

    This should then populate the subReport.....

    Tuesday, May 29, 2007 7:28 PM
  • I can get one subreport to work correctly. Each sub report has a different datasource. How do I know which datasource to assign?  My reports needs to look like the following.

     

    Main report:

    CustomerName,  CustomerId,  etc

        First Sub report:

           ContactId, ContactName, etc

       Second Sub report:

            ActivityId, ActivityName, etc

     

    When the subreportprocessing event fires how do I know which subreport i'm assigning a datasource to?

     

    Thanks for the quick reply.

     

     

    Tuesday, May 29, 2007 7:46 PM
  • I dont know about your set up...but I am working with subreports that have already got the Queries in their definition (they were designed in VS2003 and I converted them to .rdlc with VS2005). I access this query, do some string manipulation and then I return the query results...

     

     

    I then assign this as the dataSource (as in my previous post), I am using the ReportDefinition to navigate to these queries...

     

    If you need anything else then please do ask...

     

     

    Oh yeah...e.ReportPath will give you the name of the subReport being processed

    Tuesday, May 29, 2007 9:53 PM
  • I have a similar situation.  I have one main report with many subreports on it.  Here is some suedo code of my solution.  Anyone feel free to comment on it.  I would love to hear any other suggestions (I hate switch statements)

    public ReportDataSource GetSubReportDataSource(SubreportProcessingEventArgs e)
            {
                switch(e.ReportPath)
                {
                    case "InkSummaryReportMaster":
                       do this;
                    case "InkSummaryReportDetail":
                        do this;
                    case "PressJobRoutingReportMaster":
                          do this;
                    case "PressJobRoutingReportDetailRDLC":
                        do this;
                    case "PressReportHeaderRDLC":
                        do this;
                    default:
                        return new ReportDataSource();
                }
            }
    Monday, June 4, 2007 5:51 PM
  • hi!!

     

    I have a similar problem, i have a report.rdlc(main report) and sreport(subreport), the sreport needs 2 parameters one of then comes to de main report and other comes to one dropdownlist, this dropdownlist be in the page where i want to show my report. But my subreport can't be shown, i put the name of my subreport whitout extension(.rdlc), and in the place where i whant to charge my subreport i make rigth click and i select the parameter and his value.

     

    But the subreport still whitout works,

     

    webpage

    especiality:

          subreport( contains all the fields of this especiality)

    especiality:

          subreport(contains all the fields of this especiality)

    .

    .

    .

    .

    .

     

     

    thanks for the time and i hope that you or (someone than can read this post) can helpme.

     

     

    Jorge Alberto Sanchez Jasso.

     

     

     

     

     

     

    Thursday, June 7, 2007 2:54 PM
  • I use the following (pseudi code), in my app.....it might not be what everyone may use, but I find it works for me:

     

    public void LocalSubReport_Processing(object sender, SubreportProcessingEventArgs e)

    {

          string[] dSetNames = null;

          string[] dSetQueries = GetSubReportQuery(e.ReportPath, out dSetNames);

          for(int i = 0; i<dSetNames.Length; i++)

          {

                 e.DataSources.Add(new ReportDataSource(dSetNamesIdea,  GenerateDataSet(dSetQueriesIdea));

          }

    }

     

    GetSubReportQuery() accesses the subreport and finds all the queries/datasets in my .rdlc file (these were originally created in VS2003, and then converted).

    GenerateDataSet() does exactly that, it takes the queries I found and performs them and then return the required number of DataSources for this SubReport.

     

    I know this may not apply to everyone, but its what i needed to do...

    Thursday, June 7, 2007 5:38 PM
  • Hi ,

     

    I am have 3 levels subrports in my rportviewer and  I am always getting same value for e.ReportPath .

    I am able to get correctly the first subreport , but not child report of this subreport. Please help me in this regard.

     

    Thanks

    Arun

     

     

     

    Wednesday, August 22, 2007 7:30 AM
  •  

    Hi arunrc can you be more specific?

     

    i had the same problem time ago, but i give solution to my problem, and i belive can help you

     

     

    Wednesday, August 22, 2007 11:24 PM
  •  

    Hi ,

    I was trying to show a sub report inside another sub report.It didnt work and now im trying to show two
    subreports on same master report. Inside the rptViewer_SubreportProcessing event Im able to differentiate
    the two reports by checking e.ReportPath . In inside this I am binding the ReportDataSources for both the
    reports.But both the subreports are not loaded. Its Showing ' Error: Subreport could not be shown. '.
    If i comment the If e.ReportPath I am able to see one sub report and another is not working.

     

    The code is shown below.

    Protected Sub rptViewer_SubreportProcessing(ByVal sender As Object, ByVal e As SubreportProcessingEventArgs)

    Dim reportParam As ReportParams = New ReportParams()

    reportParam = Session.Item("ReportParam")

    Dim QuestionID As Int32 = Convert.ToInt32(e.Parameters("QuestionId").Values.Item(0))

    Dim dsMarketingSub As New System.Data.DataSet

    dsMarketingSub = ReportService.GetDataForMarketingQuestionSubReport(reportParam, QuestionID)

    Dim reportMarketingSub As New ReportDataSource("DataSet4_Gsp_Rpt_MarketingQuestionsSubReport", dsMarketingSub.Tables(1))

    Dim reportMarketingAnswers As New ReportDataSource("DataSet4_Gsp_Rpt_MarketingQuestionsSubReport1", dsMarketingSub.Tables(0))

    ' If e.ReportPath = "MarketingQuestionsResponsesReport" Then

    e.DataSources.Add(reportMarketingAnswers)

    'End If

    ' If e.ReportPath = "MarketingQuestionsSubReport" Then

    e.DataSources.Add(reportMarketingSub)

    ' End If

    End Sub

     

    Please help me in this regard.

     

    Thanx

    Arun

     

     

    Please help me

    Friday, August 24, 2007 11:59 AM
  •  

    hi,

     

    if your masterReport contains two subreports, is not necesary especify the reportpath, only that you need is indicate the reportdatasourse for each subreport, and becarefull whit the parameters(names,index...) that you are sending to the subreports.

     

    in the name of de reportDataSource i have the idea that needs to be compose to "datasetname_datatablename".

     

    This reports a been made whit a dataset, and the dataset create a datatableadapter in automatic, and that gime the datasourse and de datatable, an in the page where stay my reportviewer i only create a objectDataSourse and binding whit my dataset, and ind the subReportProcessing method i only put the parameters to send.

     

    this is litle piece of my code.

     

     

    Public Sub llenarsubInformes(ByVal sender As Object, ByVal e As SubreportProcessingEventArgs)

    Me.ObjectDataSource4.SelectParameters.RemoveAt(1)

    Me.ObjectDataSource4.SelectParameters.Add(New Parameter("idConvocatoria", TypeCode.Int32, Me.DropDownList1.SelectedItem.Value))

    Me.ObjectDataSource4.SelectParameters.RemoveAt(0)

    Me.ObjectDataSource4.SelectParameters.Add(New Parameter("idsolicitud", TypeCode.Int32, e.Parameters(0).Values(0).ToString))

    e.DataSources.Add(New ReportDataSource("dsInformes_informes", Me.ObjectDataSource4))

    End Sub

     

    and works pecfectly.

    Friday, August 24, 2007 5:32 PM
  • Hello cbarnes01


    were you able to do subreport in a single report?

    How did you do this?

    Thanks for you help

    Erwin
    Tuesday, April 21, 2009 8:46 AM