ilyagzak
asked on
Event handler subroutine for VB.NET SSRS subreport never gets invoked
I work in VS 2015 VB.Net
I creatd SSRS report with subrepot.
I read that to do that you have to populate both your main report and subreport in code, and for the subreport you create an event handler to populate.
In my case the subroutine that handles the event handler never gets invoked, and the subreport is not getting populated. Report displays only the main report, the subreport returns a message: Error: Subreport could not be shown.
Here are the references I have on the page:
Imports System.Data.SqlClient
Imports Microsoft.Reporting.WebFor ms
Here is my page load event:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
ReportViewer1.ProcessingMo de = ProcessingMode.Local
ReportViewer1.LocalReport. DataSource s.Clear()
ReportViewer1.LocalReport. ReportPath = Server.MapPath(".") + "/SSRSReports/" + "PvPDOrder.rdlc"
ReportViewer1.LocalReport. DataSource s.Add(GetR eportDataS ource)
AddHandler Me.ReportViewer1.LocalRepo rt.Subrepo rtProcessi ng, AddressOf SubreportProcessingEventHa ndler
Me.ReportViewer1.LocalRepo rt.Refresh ()
End If
End Sub
Public Sub SubreportProcessingEventHa ndler(ByVa l sender As Object, ByVal e As SubreportProcessingEventAr gs)
Try
e.e.DataSources.Add(GetSub reportData Source)
Catch ex As Exception
' MessageBox.Show(ex.Message , My.Application.Info.Title, MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
My problem is that the code never reaches this procedure SubreportProcessingEventHa ndler
I use a debugger, it never goes in there.
Could you please help.
I creatd SSRS report with subrepot.
I read that to do that you have to populate both your main report and subreport in code, and for the subreport you create an event handler to populate.
In my case the subroutine that handles the event handler never gets invoked, and the subreport is not getting populated. Report displays only the main report, the subreport returns a message: Error: Subreport could not be shown.
Here are the references I have on the page:
Imports System.Data.SqlClient
Imports Microsoft.Reporting.WebFor
Here is my page load event:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
ReportViewer1.ProcessingMo
ReportViewer1.LocalReport.
ReportViewer1.LocalReport.
ReportViewer1.LocalReport.
AddHandler Me.ReportViewer1.LocalRepo
Me.ReportViewer1.LocalRepo
End If
End Sub
Public Sub SubreportProcessingEventHa
Try
e.e.DataSources.Add(GetSub
Catch ex As Exception
' MessageBox.Show(ex.Message
End Try
End Sub
My problem is that the code never reaches this procedure SubreportProcessingEventHa
I use a debugger, it never goes in there.
Could you please help.
Just use th debugger to check the Page_Load event is called and what the value of IsPostBack is.
ASKER
Hi Andy,
The event handler is added, it is just never invoked, that is the issue.
Here I added two pictures to demonstrate.
On the first picture that is PageLoad event, the dubugger goes to the AddHandler line.
I believe that on the line Me.ReportViewer1.LocalRepo rt.Refresh () this event should be invokes, but it does not happen.
My second picture shows the procedure SubreportProcessingEventHa ndler that handles the event.
The debugger never gets there.
Please see the attached MS Word file with the two pictures.SubreportIssue.docxSubreportIssue.docx
The event handler is added, it is just never invoked, that is the issue.
Here I added two pictures to demonstrate.
On the first picture that is PageLoad event, the dubugger goes to the AddHandler line.
I believe that on the line Me.ReportViewer1.LocalRepo
My second picture shows the procedure SubreportProcessingEventHa
The debugger never gets there.
Please see the attached MS Word file with the two pictures.SubreportIssue.docxSubreportIssue.docx
OK. Is the subreport an rdlc file? I've found something where the event didn't fire for an .rdl subreport but a simple rename to the rdlc extension cured it.
Replace the report that you are using as the subreport, with another report, which should be super-simple, have no datasources at all, just one static textbox. Comment out AddHandler in the code. Will the subreport show up?
In the code you specify the path for the main report. What about the path for the subreport - what is the property ReportName of the subreport? is the file reportname.rdlc in place?
In the code you specify the path for the main report. What about the path for the subreport - what is the property ReportName of the subreport? is the file reportname.rdlc in place?
ASKER
My file has the extension .rdlc
I tried to put a simple subreport without a data source, it came up fine with just one text box.
Vadim, what the next step you suggest?
I tried to put a simple subreport without a data source, it came up fine with just one text box.
Vadim, what the next step you suggest?
ASKER
My subreport is in place.
If I try to rename the subreport the system gets me the error message the report is not found
If I try to rename the subreport the system gets me the error message the report is not found
Does the event fire when the report is the simple one?
also, just noticed... "e.e.DataSources" - this "e.e" - is that the way it's supposed to be?
also, just noticed... "e.e.DataSources" - this "e.e" - is that the way it's supposed to be?
ASKER
The subreport 'PvPDCastDiscrepancy' could not be found at the specified location
that is what I get when the subreport is not there
that is what I get when the subreport is not there
Allright, so now we know that the subreport source is found. But still it fails to load. At the same time, the simple subreport does load. Which probably tells us that the problem is in the "real" subreport. It fails to load, which is why the event does not fire.
Now you need to find out why the "complex" subreport does not load. I would make a copy of it and started to remove one piece after another, until it loaded. This is how you will find the critical piece responsible for the failure to load.
Now you need to find out why the "complex" subreport does not load. I would make a copy of it and started to remove one piece after another, until it loaded. This is how you will find the critical piece responsible for the failure to load.
ASKER
OK, thank you. The failure though was prior to the report being loaded. The event to handle the load did not fire up, it was nothing to handle. I will play around a bit and let you know.
ASKER
No progress unfortunately.
Still cannot make the execution to go to the subreport handler stored procedure.
It went there couple of times, then stoped going there again.
I tried to add the second subreport and removed the first one.
The execution did not go the second sub report event handler procedure.
I removed the second subreport and put back the first one.
The execution does not go into the event handler procedure that used to work.
When I put back the simple subreport with one data field it works.
Still cannot make the execution to go to the subreport handler stored procedure.
It went there couple of times, then stoped going there again.
I tried to add the second subreport and removed the first one.
The execution did not go the second sub report event handler procedure.
I removed the second subreport and put back the first one.
The execution does not go into the event handler procedure that used to work.
When I put back the simple subreport with one data field it works.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you very much for your help.
I will start another question on the topic of SSRS.
Please help!
I will start another question on the topic of SSRS.
Please help!
ASKER
Vadim gave me practical steps to take to fix the issue.
If Not IsPostBack Then
preventing the event handler being added?