.NET Forum / ASP.NET / General / June 2008
Error: Subreport could not be shown
|
|
Thread rating:  |
Herb - 24 May 2007 15:36 GMT 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?
Steven Cheng[MSFT] - 25 May 2007 02:01 GMT 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/subscriptions/managednewsgroups/default.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/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Herb - 25 May 2007 12:18 GMT 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.
> Hi Herb, > [quoted text clipped - 43 lines] > > This posting is provided "AS IS" with no warranties, and confers no rights. Herb - 25 May 2007 14:50 GMT 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?
> I have 1 .aspx form which contains 1 Webforms.ReportViewer object. The > LocalReport.ReportPath is to my REPORT1.rdlc [quoted text clipped - 55 lines] > > > > This posting is provided "AS IS" with no warranties, and confers no rights. Steven Cheng[MSFT] - 29 May 2007 08:46 GMT 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.AdventureWorksDataSet.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.
Herb - 29 May 2007 14:41 GMT 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.
> Hi Herb, > [quoted text clipped - 62 lines] > > This posting is provided "AS IS" with no warranties, and confers no rights. Steven Cheng[MSFT] - 31 May 2007 08:49 GMT 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.
Herb - 04 Jun 2007 12:23 GMT Steven,
My ReportViewer1.LocalReport does not include a SubreportProcessing command.
If you could provide VB examples, I would appreciate it.
> Thanks for your reply Herb, > [quoted text clipped - 33 lines] > > This posting is provided "AS IS" with no warranties, and confers no rights. Steven Cheng[MSFT] - 06 Jun 2007 09:09 GMT 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.
Herb - 08 Jun 2007 14:56 GMT 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?
> Thanks for your reply Herb, > [quoted text clipped - 37 lines] > > This posting is provided "AS IS" with no warranties, and confers no rights. Steven Cheng[MSFT] - 11 Jun 2007 02:40 GMT 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.
Steven Cheng[MSFT] - 13 Jun 2007 02:45 GMT 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.
Herb - 14 Jun 2007 15:31 GMT Steven, Sorry, I have been having some PC issues. I will test this by Monday and get back to you.
Thanks, Herb
> Hi Herb, > [quoted text clipped - 9 lines] > > This posting is provided "AS IS" with no warranties, and confers no rights. Herb - 14 Jun 2007 18:23 GMT 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
> Hi Herb, > [quoted text clipped - 9 lines] > > This posting is provided "AS IS" with no warranties, and confers no rights. Herb - 14 Jun 2007 19:49 GMT Forget I asked. I found that adding a second event handler did the trick. Thanks a lot for your help.
> Steven, > That worked great, thank you! [quoted text clipped - 17 lines] > > > > This posting is provided "AS IS" with no warranties, and confers no rights. Steven Cheng[MSFT] - 17 Jun 2007 14:29 GMT 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.
Chris - 21 Jun 2007 05:24 GMT 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:ObjectDataSource> for 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
Rayan Sequeira - 02 Jun 2008 17:35 GMT 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("SubReportID").DefaultValue = e.Parameters("SubReportID").Values(0) End Sub
denise co - 02 Aug 2007 23:06 GMT Hi, Steven and everybody here,
Did that work for everyone? I did the same thing advised by Steven and still have the same problem. Anyone see what the problem is? Thanks. I used the sql northwind database for testing.
Denise
========================================== public partial class _Default : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) { this.ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("CustomerOrderDataSet_Customers", CustomerDataSource.ID)); this.ReportViewer1.LocalReport.SubreportProcessing += new SubreportProcessingEventHandler(this.SetSubDataSource); this.ReportViewer1.LocalReport.Refresh(); }
public void SetSubDataSource(object sender, SubreportProcessingEventArgs e) { e.DataSources.Add(new ReportDataSource("CustomerOrderDataSet_Orders", OrderDataSource.ID)); }
} =============================================
Manikandan Pushkaran - 26 May 2008 09:18 GMT Dear All
I made a Header Report and a Detail report, the detail report having a report parameter, the header report am refreshing with a value when we select a value from the drop down and refresh, how ever my detail report is not refreshing with the parent report, parent report refresh its data.
so how can i do this, here my problem is, i am not able to filter the subreport value, corresponding to the master report filter.
did any one did this if yes please help in doing this.
good day
Thanks in advance
Manikandan
Free MagazinesGet these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...
|
|
|