Friday, February 17, 2012

Error: Subreport could not be shown

I am a new one in using ReportViewer in VS 2005. I try to use Main and Sub report to show data from my dataset. It doesn't matter if I use main report only, but the problem is when I use subreport intergrated with the main report. When I run it in browser, it shows:

Error: Subreport could not be shown

The main report is ok.Is there any solution to the problem?

Thank for your help!!!!Hello,

Are you able to view the subreport if you navigate to it directly? If so, you probably havean issue with the subreport reference in the parent report.|||

hi mike,

How can we set sub report references in the parent report of reportviewer?

If you have a ready code or steps pls post since its urgent.

thanks and regards,

unni

|||

http://gotreportviewer.com has some examples of using subreports. Have you looked at those?

-Albert

|||

hi albert,

i tried the url and i used the code meant for subreport processing but the event doesnt get fired.

the dataset for subreport can only be set if the event gets fired. i will attach the code to make it more clear

Dim params(3) As ReportParameter


params(0) = New ReportParameter("ClientName", CStr(Session("ClientID")))
params(1) = New ReportParameter("Service", CStr(Session("ServicePeriodID")))
params(2) = New ReportParameter("FullName", CStr(Session("FullName")))
params(3) = New ReportParameter("ServiceName", CStr(Session("Period")))

Me.rvBusinessInc.ProcessingMode = ProcessingMode.Local
rvBusinessInc.LocalReport.DataSources.Add(New Microsoft.Reporting.WebForms.ReportDataSource("t1", DSBIReport))
rvBusinessInc.LocalReport.DataSources.Add(New Microsoft.Reporting.WebForms.ReportDataSource("t2", DSAgency))
AddHandler rvBusinessInc.LocalReport.SubreportProcessing, AddressOf LocalReport_SubreportProcessing

rvBusinessInc.LocalReport.SetParameters(params)
rvBusinessInc.LocalReport.Refresh()

I'm still gettin the error as subreport cannot be found.
thanks and regards,
unni

|||

Run your website in the debugger and enable catching all exceptions. Are any exceptions being throwh?

-Albert

|||

Hi,

I ran into same problem and found the follwoing two reasons for subreport error:

1. Make sure that all the parameters of the subreport have been assigned a value during design

2. Also, if you are referencing/using any external DLLs or classes from .Net Framerwork (see references tab in report properties dialog) then make sure that you confugure report viewer control for that.

Good Luck!

Naqsh

|||Hi,
I am having a lot of trouble with the report viewer as well. No matter what I try I get Error: Subreport cannot be displayed.
This is the latest code that i am using:

Imports Microsoft.Reporting.WebForms

Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles form1.Load

'Wire up the event that will allow us to bind the sub report
AddHandler ReportViewer1.LocalReport.SubreportProcessing, AddressOf ReportViewer_SubreportProcessing
ReportViewer1.LocalReport.Refresh()

End Sub

Private Sub ReportViewer_SubreportProcessing(ByVal sender As Object, ByVal e As SubreportProcessingEventArgs)
Dim params(1) As ReportParameter
params(0) = New ReportParameter("questionid", CStr(e.Parameters("questionid").ToString))
ReportViewer1.LocalReport.SetParameters(params)
ReportViewer1.LocalReport.DataSources.Add(New Microsoft.Reporting.WebForms.ReportDataSource("DataSet2_templBPQues", ObjectDataSource2))
End Sub

End Class

|||

Hi,

First, You should not be using subreportprocessing event to set the main report parameters.

Does your report has one subreport or more than one? Look at the example code which comes with VS 2005.

Naqsh

|||I am just building some test reports to get an idea of how it all works but my project report has 3 subreports.|||

Nope I can't see anyway to set the subreport parameters from id values passed from the Main report. Can you post an example of how this is done. There are no examples of how to do this anywhere. They all gloss over this unless it means you don't have to in which case my report has some other problem.

Thanks very much.

|||Don't know if you are still struggling with this one, but passing parameters to subreports is simply a case of right click on the subreport where you have included it in the main report, open the Properties and Parameters Tab and specify the link between the main and subreport. As long as you have set up the correct filter in the subreport design itself, you should just be able to pick from the drop downs and choose the corresponding column to assign it to from the main dataset.....

No comments:

Post a Comment