By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,659 Members | 910 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,659 IT Pros & Developers. It's quick & easy.

Error: Subreport could not be shown

P: n/a
I have created a report and subreport in VB/ASP.NET. The report works fine
but the subreport will not display. The subreport, when displayed as a
standalone report, works fine.

Any help I can find on this error refers to the WinForms.ReportViewer and
none to the WebForms.ReportViewer.

Anyone have any guidance?
May 24 '07 #1
Share this Question
Share on Google+
17 Replies


P: n/a
Hi Herb,

From your description, you are using webform reportviewer to display two
SSRS report(client or server report?) in ASP.NET web page. However, the
main report display ok, but the subreport didn't display, correct?

As for the Sub report, have you tried any other very simple report to see
whether it is specific to the sub report's structure or content. Also, when
running the report, what's the error message you get for the subreport when
try displaying it?

Please feel free to let me know if there is anything I missed or if you
have any other finding on this.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

May 25 '07 #2

P: n/a
I have 1 .aspx form which contains 1 Webforms.ReportViewer object. The
LocalReport.ReportPath is to my REPORT1.rdlc

REPORT1.rdlc has a subreport with a ReportName of SUBREPORT1

There are no parameters passed between report and subreport.

When I run this, I get the "Subreport could not be shown" error.

If I add a second WebForms.ReportViewer to my .aspx form and link it to
SUBREPORT1.rdlc, it works fine.

"Steven Cheng[MSFT]" wrote:
Hi Herb,

From your description, you are using webform reportviewer to display two
SSRS report(client or server report?) in ASP.NET web page. However, the
main report display ok, but the subreport didn't display, correct?

As for the Sub report, have you tried any other very simple report to see
whether it is specific to the sub report's structure or content. Also, when
running the report, what's the error message you get for the subreport when
try displaying it?

Please feel free to let me know if there is anything I missed or if you
have any other finding on this.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

May 25 '07 #3

P: n/a
Additionally, when I link a very simple subreport (text only), it works.

My SUBREPORT1.rdlc refers to a data source and uses a SESSION variable for
it's criteria. Must it use a parameter from the main report?

"Herb" wrote:
I have 1 .aspx form which contains 1 Webforms.ReportViewer object. The
LocalReport.ReportPath is to my REPORT1.rdlc

REPORT1.rdlc has a subreport with a ReportName of SUBREPORT1

There are no parameters passed between report and subreport.

When I run this, I get the "Subreport could not be shown" error.

If I add a second WebForms.ReportViewer to my .aspx form and link it to
SUBREPORT1.rdlc, it works fine.

"Steven Cheng[MSFT]" wrote:
Hi Herb,

From your description, you are using webform reportviewer to display two
SSRS report(client or server report?) in ASP.NET web page. However, the
main report display ok, but the subreport didn't display, correct?

As for the Sub report, have you tried any other very simple report to see
whether it is specific to the sub report's structure or content. Also, when
running the report, what's the error message you get for the subreport when
try displaying it?

Please feel free to let me know if there is anything I missed or if you
have any other finding on this.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.


May 25 '07 #4

P: n/a
Hi Herb,

I've performed some local tests and also found the problem when I use a
subreport that bind with some datasources. And after some further research,
I found an existing issue, this is due to the subreport also need to define
its datasource in the main report's page. Actually, both the main report
and subreport will look for datasource/dataset from the hosting aspx
page(where the reportviewer reside). Do you think this is the cause of your
problem. If so , here is a solution to it:

*** Problem Description ***
If you show a report with a subreport in the ReportViewer control and the
ReportViewer control is set to "local", you will get these error messages:

in the VS output window: Warning: An error occurred while executing the
subreport
'subreport1': An error has occurred during report processing.
(rsErrorExecutingSubreport)

in the ReportViewer, we get the message: Error: Subreport could not be shown

<><><><><><><><><><><><><><><><><><><><><><><><><> <><><><><><><><><><><><><>
<>
*** Resolution ***
In the form that contains the ReportViewer control, you must add an event
handler.
In that event handler, you must manually bind the subreport datasource:
--------------------------------------------------------
Private Sub Local_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the
'AdventureWorksDataSet.Contact' table. You can move, or remove it, as
needed.
Me.ContactTableAdapter.Fill(Me.AdventureWorksDataS et.Contact)

Dim instance As LocalReport = Me.ReportViewer1.LocalReport
AddHandler ReportViewer1.LocalReport.SubreportProcessing, AddressOf
Me.SetSubDataSource

Me.ReportViewer1.RefreshReport()
End Sub

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

e.DataSources.Add(New ReportDataSource("AdventureWorksDataSet_Contact",
Me.AdventureWorksDataSet.Contact))
End Sub
--------------------------------------------------------

The table name is derived from the table adapter and the data source name
must be
copied from the report's datasources.
==================================

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

May 29 '07 #5

P: n/a
I think you will find this example is for the Winforms.ReportViewer, not the
Webforms.ReportViewer. There is no .RefreshReport for the webforms version.
Did you try this in a web application? I was unable to get this to work in a
web application.

"Steven Cheng[MSFT]" wrote:
Hi Herb,

I've performed some local tests and also found the problem when I use a
subreport that bind with some datasources. And after some further research,
I found an existing issue, this is due to the subreport also need to define
its datasource in the main report's page. Actually, both the main report
and subreport will look for datasource/dataset from the hosting aspx
page(where the reportviewer reside). Do you think this is the cause of your
problem. If so , here is a solution to it:

*** Problem Description ***
If you show a report with a subreport in the ReportViewer control and the
ReportViewer control is set to "local", you will get these error messages:

in the VS output window: Warning: An error occurred while executing the
subreport
'subreport1': An error has occurred during report processing.
(rsErrorExecutingSubreport)

in the ReportViewer, we get the message: Error: Subreport could not be shown

<><><><><><><><><><><><><><><><><><><><><><><><><> <><><><><><><><><><><><><>
<>
*** Resolution ***
In the form that contains the ReportViewer control, you must add an event
handler.
In that event handler, you must manually bind the subreport datasource:
--------------------------------------------------------
Private Sub Local_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the
'AdventureWorksDataSet.Contact' table. You can move, or remove it, as
needed.
Me.ContactTableAdapter.Fill(Me.AdventureWorksDataS et.Contact)

Dim instance As LocalReport = Me.ReportViewer1.LocalReport
AddHandler ReportViewer1.LocalReport.SubreportProcessing, AddressOf
Me.SetSubDataSource

Me.ReportViewer1.RefreshReport()
End Sub

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

e.DataSources.Add(New ReportDataSource("AdventureWorksDataSet_Contact",
Me.AdventureWorksDataSet.Contact))
End Sub
--------------------------------------------------------

The table name is derived from the table adapter and the data source name
must be
copied from the report's datasources.
==================================

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

May 29 '07 #6

P: n/a
Thanks for your reply Herb,

Yes, the original issue record is for a winform reportviewer issue,
however, it also applies to webform scenario. And I did change the code in
my local test page, but forgot to modify it when paste the original code
snippet to you. Here is the test code in my test page:

(you need two datasources on the page, one for your main report and another
for the subreport)
===========================
public partial class test_reportpage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ReportViewer1.LocalReport.SubreportProcessing += new
SubreportProcessingEventHandler(SetSubDataSource);
this.ReportViewer1.LocalReport.Refresh();
}

public void SetSubDataSource(object sender,
SubreportProcessingEventArgs e )
{
e.DataSources.Add(new ReportDataSource("DataSet1_rpt_table",
"ObjectDataSource1"));

}
}
=============================

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

May 31 '07 #7

P: n/a
Steven,

My ReportViewer1.LocalReport does not include a SubreportProcessing command.

If you could provide VB examples, I would appreciate it.

"Steven Cheng[MSFT]" wrote:
Thanks for your reply Herb,

Yes, the original issue record is for a winform reportviewer issue,
however, it also applies to webform scenario. And I did change the code in
my local test page, but forgot to modify it when paste the original code
snippet to you. Here is the test code in my test page:

(you need two datasources on the page, one for your main report and another
for the subreport)
===========================
public partial class test_reportpage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ReportViewer1.LocalReport.SubreportProcessing += new
SubreportProcessingEventHandler(SetSubDataSource);
this.ReportViewer1.LocalReport.Refresh();
}

public void SetSubDataSource(object sender,
SubreportProcessingEventArgs e )
{
e.DataSources.Add(new ReportDataSource("DataSet1_rpt_table",
"ObjectDataSource1"));

}
}
=============================

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 4 '07 #8

P: n/a
Thanks for your reply Herb,

For VB.NET page, you can directly type the
"reportViewer.LocalReport.SubReportProcessing" event regardless of the
intellisense support. Here is the converted VB.NET version of my test
page's codebehind:

=========================
Imports Microsoft.Reporting.WebForms

Partial Class vb_vbreportpage
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
AddHandler ReportViewer1.LocalReport.SubreportProcessing, AddressOf
SetSubDataSource
ReportViewer1.LocalReport.Refresh()

End Sub
Public Sub SetSubDataSource(ByVal sender As Object, ByVal e As
SubreportProcessingEventArgs)

e.DataSources.Add(New ReportDataSource("DataSet1_rpt_table",
"ObjectDataSource1"))

End Sub

End Class
============================

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 6 '07 #9

P: n/a
Thanks for the reply, sorry I have been away fromthis project for a while and
some of this has slipped my mind. When you refer to:
e.DataSources.Add(New ReportDataSource ("DataSet1_rpt_table",
"ObjectDataSource1"))
what is meant by the ObjectDataSource1? I understand the DataSet1_rpt_table
is the dataset of the subreport. Is the ObjectDataSource1 the view which the
dataset refers to?

"Steven Cheng[MSFT]" wrote:
Thanks for your reply Herb,

For VB.NET page, you can directly type the
"reportViewer.LocalReport.SubReportProcessing" event regardless of the
intellisense support. Here is the converted VB.NET version of my test
page's codebehind:

=========================
Imports Microsoft.Reporting.WebForms

Partial Class vb_vbreportpage
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
AddHandler ReportViewer1.LocalReport.SubreportProcessing, AddressOf
SetSubDataSource
ReportViewer1.LocalReport.Refresh()

End Sub
Public Sub SetSubDataSource(ByVal sender As Object, ByVal e As
SubreportProcessingEventArgs)

e.DataSources.Add(New ReportDataSource("DataSet1_rpt_table",
"ObjectDataSource1"))

End Sub

End Class
============================

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 8 '07 #10

P: n/a
Hi Herb,

The "ObjectDataSource1" is the ID of a ObjectDataSource control which
supply the datasource(DataSet) for the report(displayed in ReportViewer).
Actually in Visual Studio 2005 designer, when you choose a client rdlc
report in the ReportViewer, it will automatically generate an
ObjectDataSource control in aspx page for you. However, here since you use
subreport, you need to manually add an ObjectDataSource control that can
supply dataset for your subreport. However, one trick to add such a
ObjectDataSource is add another ReportViewer that display the subreport
individually, and it can automatically help you generate such a DataSource
control. After that you can remove the temp reportViewer and keep the
ObjectDataSource and use it for the first ReportViewer (that use sub
report).

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 11 '07 #11

P: n/a
Hi Herb,

Have you got any progress? Does the further info in my last reply also
helps some?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 13 '07 #12

P: n/a
Steven,
Sorry, I have been having some PC issues. I will test this by Monday and get
back to you.

Thanks,
Herb

"Steven Cheng[MSFT]" wrote:
Hi Herb,

Have you got any progress? Does the further info in my last reply also
helps some?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 14 '07 #13

P: n/a
Steven,
That worked great, thank you!

Next question. I need to add ANOTHER subreport to this report. Is that
possible? Should I close this topic and start a new question?

Thanks

"Steven Cheng[MSFT]" wrote:
Hi Herb,

Have you got any progress? Does the further info in my last reply also
helps some?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 14 '07 #14

P: n/a
Forget I asked. I found that adding a second event handler did the trick.
Thanks a lot for your help.

"Herb" wrote:
Steven,
That worked great, thank you!

Next question. I need to add ANOTHER subreport to this report. Is that
possible? Should I close this topic and start a new question?

Thanks

"Steven Cheng[MSFT]" wrote:
Hi Herb,

Have you got any progress? Does the further info in my last reply also
helps some?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
Jun 14 '07 #15

P: n/a
Thanks for your followup Herb,

Glad that you've got it working.

Have a good day!

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Jun 17 '07 #16

P: n/a
Hi Steven or Herb (or anyone),

I followed this discussion carefully - it seems to match my situation
very closely, but I did not get the success that Herb did at the end.

I'm working in Visual Web Developer 2005, using ASP.NET and VB 2005.

I am trying to create a report with a sub-report.

I first got a basic main report going - created a dataset based on
a simple query, and have no problem generating simple reports using
the ReportViewer control and a corresponding ObjectDataSource that
refers to the dataset tableadapter.

Next I created a "static" subreport (just to try walking before
crawling!). It does not depend on any dataset - it just provides
some static text. I include that as a sub-report in my main report
and it works fine.

Next I created a new dataset for the "real" sub-report. It takes a
single parameter - the key field from the "main" dataset. The aim is
that, when coupled with the main report, it will return the related
records in the sub-dataset for each record in the main report/dataset.
I test this sub-report by hard-coding a default value for the
parameter and it works fine as a stand-alone report, displaying the
correct related records from the sub-dataset for the hard-coded
parameter key value.

So... the last step is to put the sub-report into the main report. I
drop a subreport control into the main report's list control just
like I did with the static sub-report, right-click on it to open
the Properties dialog, choose the "real" sub-report (not the static
one this time) in the General tab, and finally set the parameter on
the Parameters tab (parameter name is SiteID, parameter value is
set from the drop-down to =Fields!SiteID.Value). This was my first
attempt and I thought it would be sufficient, but instead of getting
the sub-reports I get the error message:

Error: Subreport could not be shown.

That's when I found your recent discussion, and I tried what seemed to
be the 2 key issues in the solution: (1) adding some code-behind to
set the sub-datasource in the processingevent handler, and (2) adding
an <asp:ObjectDataSourcefor the sub-dataset to the aspx page. Having
done both of those, the error remains.

I set a breakpoint in the SetSubDataSource() handler - it never
fires, so I infer that the SubreportProcessing event is not being
raised(?).

I'm sure the devil is in the details, and I can provide those to
you as we go - this message is already too long, so I'll leave it
here for now and hope to hear from one of you soon... Thanks in
advance!

Chris

*** Sent via Developersdex http://www.developersdex.com ***
Jun 21 '07 #17

P: n/a
This Worked for me. Try this
I Created a Main report with a subreport which takes one parameter from
the Main Report. I Added the following code.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
AddHandler rvReport.LocalReport.SubreportProcessing,
AddressOf SetSubDataSource
rvReport.LocalReport.Refresh()
End Sub

Public Sub SetSubDataSource(ByVal sender As Object, ByVal e As
SubreportProcessingEventArgs)
e.DataSources.Add(New ReportDataSource("SubReport",
"ObjectDataSourceSubReport"))

ObjectDataSourceSubReport.SelectParameters("SubRep ortID").DefaultValue =
e.Parameters("SubReportID").Values(0)
End Sub

*** Sent via Developersdex http://www.developersdex.com ***
Jun 27 '08 #18

This discussion thread is closed

Replies have been disabled for this discussion.