ReportViewer1 LocalReport SubreportProcessing event doesn't fire

Answered ReportViewer1 LocalReport SubreportProcessing event doesn't fire

Alle Antworten

  • Freitag, 27. Mai 2005 02:52
     
     Beantwortet
    You can get that error if the RDL for the subreport cannot be found, or if you haven't supplied data for all the datasets expected by the subreport, or if the main report didn't pass a parameter expected by the subreport.
  • Freitag, 27. Mai 2005 03:33
     
     

    Here's some sample code:

    Imports System
    Imports System.Data
    Imports System.Windows.Forms
    Imports Microsoft.Reporting.WinForms

    Public Class Demo
        Inherits Form

        Private orderDetailsData As DataTable = Nothing

        Private Function LoadOrdersData() As DataTable
            ' Load data from XML file
            Dim dataSet as DataSet = new DataSet()
            dataSet.ReadXml("OrderData.xml")
            return dataSet.Tables(0)
        End Function

        Private Function LoadOrderDetailsData() As DataTable
            ' Load data from XML file
            Dim dataSet as DataSet = new DataSet()
            dataSet.ReadXml("OrderDetailData.xml")
            return dataSet.Tables(0)
        End Function

        Private Sub DemoSubReportProcessingEventHandler( _
                   ByVal sender As Object, ByVal e As SubreportProcessingEventArgs)
            If orderDetailsData Is Nothing Then
                orderDetailsData = LoadOrderDetailsData()
            End If
            e.DataSources.Add(New ReportDataSource("DataSet1_OrderDetails", orderDetailsData))
        End Sub

        Public Sub New
            me.Text = "Report Control Demo"
            me.ClientSize = new System.Drawing.Size(700, 500)

            Dim reportViewer as ReportViewer = new ReportViewer()

            ' Set Processing Mode

            reportViewer.ProcessingMode = ProcessingMode.Local

            ' Set RDL file

            reportViewer.LocalReport.ReportPath = "Orders.rdlc"

            ' Add a handler for SubreportProcessing

            AddHandler reportViewer.LocalReport.SubreportProcessing, _
                      AddressOf DemoSubReportProcessingEventHandler

            ' Supply a DataTable corresponding to each report data source

            reportViewer.LocalReport.DataSources.Add( _
                new ReportDataSource("DataSet1_Orders", LoadOrdersData()))

            ' Add the reportviewer to the form

            reportViewer.Dock = DockStyle.Fill
            me.Controls.Add(reportViewer)

            ' Process and render the report

            reportViewer.RefreshReport()
        End Sub

        Public Shared Sub Main(args as string())
            Application.Run(new Demo())
        End Sub
    End Class

  • Freitag, 27. Mai 2005 12:58
     
     

    Rajeev, Thanks for the replies.

    You are right, my subreport had error. It would be nice in the final version we can see some error message when compiling or runtime.

    I have another question.

    I am doing like your demo code. a little differnent is I fill my dataset first, which include two datatables for all of  the masters and details. Then in subreportprocessing event, I use details datatable.select to filter details by the e.parameter. I design it this way assuming it is much faster than going to database to get detail every time subreportprocessing fires.

    But the performance is very bad, it took almost 5+ seconds to run 20+ master rows, 100+ detail rows report. It seems the botteneck is the every datatable.select statement.

    What is your suggestion? From the RS BOL, I know performance is better to use data region than subreport. But it should not be that worse, I think I am doing something wrong here.

    Wei

  • Freitag, 27. Mai 2005 18:08
     
     
    One thing you can try is to do the filtering in RDL instead of doing datatable.select. In my sample code I am supplying the same data each time the SubreportProcessing event fires, and then using a filter expression in the subreport RDL. You should still try to avoid subreports if you can, for performance reasons.
  • Freitag, 27. Mai 2005 19:03
     
     
    Filter in RDL of subreport does help improve performance. But still not good enough, I said it takes 5+ seconds if I use datatable.select, now I think I under estimated it. I would say it takes 10+ seconds if use datatable.select, 5+seconds if use filter in subreport.

    So it is a improvement. But still not good enough compared to my Access report. You know I am importing 150+ reports from MS Access.  The same report in access only takes 2- seconds. Something can be done to improve the subreport performance, maybe the engine, maybe RDL of my report. don't know.
  • Montag, 11. Juni 2007 21:31
     
     

    Hi all,

     

    I was reading this thread (as I struggle to get subreports working) and something in this response confused me.  You wrote that some possible reasons that the subreportProcessing event isn't being triggered could be:

     

    You can get that error if the RDL for the subreport cannot be found, or if you haven't supplied data for all the datasets expected by the subreport, or if the main report didn't pass a parameter expected by the subreport.

     

    Here's what I don't understand:  Isn't the whole point of the subreportProcessing event firing is that that's the point at which I should take the currently selected values of the parent report parameters in order to fetch the data for all the datasets expected by the subreport?

     

    Then again, I still haven't been able to get that event to fire, so I might be way off.

     

    Thanks for your time in advance,

    Jeremy

  • Mittwoch, 7. März 2012 23:07
     
     

    hello

    I hav the same problem, I need to use a subreport to show  some detail for every row on the main report,  and I got "

    • An error occurred during local report processing.
      • Value cannot be null. Parameter name: value

    "

    I dont know why , my situation is

    the sub reoprt is in the same directory than the main report
    the subreport request 2 parameters in order to call some bussines object and fill the data, I will do this in the ReportViewer1.LocalReport.SubreportProcessing

    The event NEVER raise,.. I guess because the error

    do u have some complete example , so I can download to really understand how to work with subreports?

    THANKS IN ADVANCE


    Salu2 Sergio T

  • Freitag, 11. Mai 2012 14:08
     
     

    C# 2010 SP1, 

    Hi there,

    I have the same issue.

    My Parent report is fine. My Child report1 is fine as well (Has data), but I do not know how to fire           reportViewer1.LocalReport.SubreportProcessing +=  new SubreportProcessingEventHandler(ContactSupplierProcessingEventHandler);

    Please help

    Alex

  • Montag, 14. Mai 2012 20:57
     
     Vorgeschlagene Antwort

    Never mind i Found it


    Alex

    • Als Antwort vorgeschlagen Alex_00 Montag, 14. Mai 2012 20:57
    •  
  • Mittwoch, 23. Mai 2012 23:21
     
     

    If you have a ReportViewer.Reset, your AddHandler must follow it.

    ReportViewer1.Reset()

    AddHandler ReportViewer1.LocalReport.SubreportProcessing, AddressOf LocalReport_SubreportProcessing