Home » Asp.net

Report Viewer-Report with Subreport


I have a reportviewer control (2010) on my form with the following definition.

<rsweb:ReportViewer ID="ReportViewer1" runat="server">
<LocalReport ReportPath="Report1.rdlc">
<rsweb:ReportDataSource DataSourceId="dsApplicants" Name="DataSet1" />
<asp:SqlDataSource ID="dsApplicants" runat="server"
SelectCommand="SELECT * FROM [fApplicants]" ConnectionString="<%$ ConnectionStrings:Club CS%>">

Report 1 has a Subreport, how can I set the Datasource for SubReport?


4 Answers Found


Answer 1


Please refer to these:

































ObjectDataSource1 is the datasource for Main report  ,ObjectDataSource2 is the datasource for subreport.

Challen Fu


Answer 2

Thanks Fu,

Actually I am new to ASP.NET a and SSRS.

Now I am getting tis error:

Data retrieval failed for the subreport, 'Subreport1', located at: c:\inetpub\wwwroot\<>\Report2.rdlc. Please check the log files for more information.

Report is workins fine in BI studio but not in report  Viewer.

And How can I view log files?


Answer 3

There is some difference between Reporting Service and RDLC local report, we could drag a subreport  into main report  and set this subreport’s name and its parameters, then it will display correctly in the main report, however, we could not just do this in RDLC local report as in reporting service. We could display the subreport by adding an event handler for the SubreportProcessing event of the ReportViewer control. Then, manually set the data source for the report in the event handler process. Just like below code-behind:

private void <FormName>_Load(object sender, EventArgs e)



            Other code is here.



            this.reportViewer1.LocalReport.SubreportProcessing +=

            new SubreportProcessingEventHandler(SubreportProcessingEventHandler);



            Other code is here.



void SubreportProcessingEventHandler(object sender, SubreportProcessingEventArgs e)


            e.DataSources.Add(new ReportDataSource("AdventureWorksDataSet_Contact", this.AdventureWorksDataSet.Contact ));


This is the same thread; you could click this link to get a reference http://forums.asp.net/t/1479083.aspx

Please feel free to ask.

Best regards,

Challen Fu


Answer 4

Thank you very much Fu.



I have one main report containing one subreport containing another subreport.

Invoices (Main report)

        Invoice (sub report)

                Details (sub report)

In the subreportprocessing event I pass a datatable to the details subreport. At runtime on every page of the report it displays only the details for the first invoice in the nested subreport. I stepped into code and the datatable seems to have the right data but the display is wrong. The code worked on Report Viewer 2008 and works with 2010 for the scenario with the Invoice as the main report and details the only sub report. It seems that if i nest more than 1 level of subreport things go wrong. Anyone has some ideeas?



Hi, could you please send me an example of project from visual studio 2008 using reportviewer with subreports where I have to use parameters in the subreport with the method SubreportProcessingEventHandler()



Hi All,

        I am using report viewer control to display reports. I have one main report which contains 3 subreports(There are 4 rdlc files, the main rdlc file is mapped to the report viewer by default). The main report contains three link columns. Once the main report loads, On clicking the each link the main report along with the respective subreport should open. The visibility of the Subreports must change according to the click of the link in the main report. There is one rdlc file for each report.

I have declared SubReportProcessingEvent as a sub report processing handler shown below.

 AddHandler rvCompareLabels.LocalReport.SubreportProcessing, AddressOf SubReportProcessingEvent

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

In this method how will i identify which link was clicked and based on that how will I add the data source  for each sub report. I am using VS2008.

Has anyone come across a similar kind of requirement or can you give me any idea.

Any suggestions would be really helpful. Thanks.

I have the report in the the following format. (For a Tender)

Eveything is inside a list.

<Tender Master Details>

<Sub Report: Tender Items> - KeepTogether=False

<Tender Sign Area>

When I print this out it always comes in 3 pages if the tender items can not fit in the first page. It leaves a massive white space in the first page and jumps to the second.

I thought the explicit KeepTogether property was fixed in Visual Studio 2010 and Report Viewer 2010.

Can someone tell me how to get this fixed?



I have a report and a .NET 3.5 Winforms application which displays the report in local mode, passing the required datasets to the report as it is supposed to do. It takes about 2 seconds before the report is displayed.

However, when I click on Print Layout, the "Loading..." box appears and does not disappear any more. If I want to print the report, a window appears telling me that the first page is being sent to the printer and... that's it, all I can do is kill my application via task manager.

After playing around with various elements in my report, I was able to reproduce this behaviour if one of my subreport returns too many rows (the subreport contains only a list element, listing all records).

I believe it has something to do with the subreport spanning more than one page. I played with the KeepTogether property on various elements, but to no avail. Has anybody experienced something like this before? Is there a workaround?




I would like to give feedback to the sql reporting services advanced team

I would love to see  sql report viewer using silverlight I am a bit
disappointed that it is not available now. 
Can we  expect this in  with vs 2010?
Thank you


hi, i decided to export my local site to iis today, the process wasn't smooth.


anyway. i was able to access my site, the db tables are working as i am able to create new records and retrieve them. my main problem now is with the report object. i've tried the work around found here : http://support.microsoft.com/kb/2002980.. it helped sort of. i used to have only a big page of error before i did the work around, now i am able to see half of the report (the report interface) but the contents, the field are filled with 404 errors.

any idea how i can fix this??











I am having a problem with the wait graphic and load screen in Report Viewer.  I am using MS Report Viewer 10 with Visual Studio 2008 with SQL Server 2008 R2.


The problem is that when I try to embed the Report Viewer in another page the little spinning wait graphic doesn't show up and the Toolbar shrinks in width to a quarter of what it is when the report finally loads.  I have read the forums regarding setting the Asynchronous Rendering to true/false but the issue still doesn't go away after that.  The wait graphic and toolbar width were working fine when I was using ReportViewer 9 but when I switched to 10 that is when this became a problem.  Could someone please get back to me, I am stuck and don't know what else to do to get this thing to show that pretty spinning wheel.  I am using WebForms 3.5 and ReportingServices2005.



I searched the forum but couldn't find anyone with the same problem with me.  They were close but didn't help me solve my issue.

I'm trying to learn how to make the sub-report get data from SQL Server based on a primary key passed from the main-report.

An example:
Main report displays all student names and the sub-report would display all their contact phone numbers.

A visual:
Bobby Smith

Home Phone: 555-1212
Cell Phone: 555-2323
Work Phone: 555-3434

Jane Doe

Home Phone: 555-2020
Cell Phone: 555-3030
Work Phone: Null

Ginger Doe

Home Phone: 555-5062
Cell Phone: 555-9586
Work Phone: 555-2356

Student ID   |   Name
1                | Bobby Smith
2                 | Jane Doe
3                 | Ginger Doe

Phone ID     |     Student ID    |        Number       |    Type
1                 |        1              |        555-1212      |  Home
2                 |        1              |        555-2323      |  Cell
3                 |        1              |        555-3434      |  Work
4                 |        2              |        555-2020      |  Home
5                 |        2              |        555-3030      |  Cell
6                 |        2              |        555-5062      |  Home
7                 |        3              |        555-9586      |  Cell
8                 |        3              |        555-2356      |  Work


What I have working:

I have the main report listing all the student's names by creating a dataset (.xsd) in my App_Code folder and adding a TableAdapter with the query "Select * from Student".  I then created a report (.rdlc) and dragged and dropped the Name field from the dataset.  This all works fine.

Now I'm trying to add the sub-report to list the student's phone number and that is where I'm stuck.

I started doing the same thing as the main form.  First create my dataset (.xsd) in my App_Code folder and adding a TableAdapter.  I tried putting the query as "Select * from Phone where Phone.StudentID = @StudentID". I used @StudentID because I want to be able to send a variable to get the results (that's what I'm thinking).  Then I try to create the report (.rdlc) and drag the phone fields from the dataset.  I also try to set the Parameters and now I'm totally lost because the sub-report bombs all the time with the message "error subreport could not be shown".  Any help would be appreciated.

I know I can use a table or matrix to accomplish this, but I want to learn to use SubReports.  THANKS!!!


I've got 2 folders:



In the Finance folder I have a Sales report that has 3 subreports, and a salesregion parameter.

I created a linked report in /Japan to /Finance/Sales, hide the salesregion parameter, and set the default to Japan, so they can only see their region's sales data.

But when a Japan user runs the Sales report, they get Error: Subreport could not be shown because they do not have access to the /Finance folder. Any ideas?


Visual Studio 2010 report designer:

How can we put the Plus sign off if there are no records available in the subreport? (This option is enabled by check marking "Display can be toggled by this report item" prompt at the Sub report properties dialog box.



We recently upgraded a report server and corresponding reports from SQL Server 2000 (reports 2003) to SQL Server 2005. After upgrade one of our reports which use two subreport is very very slow.

The sp's used for these all these reports are fast. All the sp's together takes about 40 secs.

Both in the BIDS environment as well as the report site the report is very slow.

We are using a database in which data is inserted through replicatoin. In all our sp's we have given 'with nolock' along with the table names.

Can anyone please help me here?


I have a subreport with parameters where the value is bound to a field from the dataset on the parent report. The subreport is reused on many parent reports in my project. This is how the a parameter on the subreport is set from the parent report:

=First(Fields!AccountName.Value, "dsCustomerReport_dtCustomer")


My observation and problem is that when the parent report contains a tablix, matrix or list, the parameters discussed above are not set (Null).  However when I delete the tablix, matrix or list off the parent report and run the application, the parameters are set correctly.  This observation is true for several reports in my project.

No one else seems to have run into this problem.  Is there something that I can do to correct it?

The project is a windows forms application with Visual Studio 2010, report viewer 10, .NET 3.5. I recently upgraded from VS 2008


I cannot find a direct solution to this problem.  My workarounds are as follows:

1.Remove the parameters and bind the controls on the subreport to a datatable.

2.Remove the binding of the parameter from the parents dataset, and manually set the parameter value in code.

Each of these workarounds present a difficulty and it would be best if I could identify a direct solution to the problem.

Many Thanks.


I am using SSRS 2008 in integrated mode on a WSS 3.0 site.  I have a report with a matrix in it.  THere are two columns (Project/task).  When I expand the project column (clicking +), the tasks will show up.   Everything works fine in BIDS.  But when I try to view the same report in WSS, the numbers in the columns beyond task get pushed over by 1 column whenver I expand the project column.  

For example, this is what the report looks like before I expand the project column -

Project              MTD    YTD
+ProjectA           100    200
+ProjectB           300    400

After I click +, I get

Project              MTD    YTD
+ProjectA       Task 1     10    20
                      Task 2    90    180
+ProjectB           300    400

Does anyone know how to fix this?




In our environment, we have both an Integrated and Native mode SSRS installation.  We would like to display one of the reports from Native mode in our SP site, basically just to prove out that it can be done.  We already display in Integrated mode report using SQL Server Reporting Services Report Viewer webpart.  I have tried using this web part to display a native mode report, because it makes it sound like you can, but it says the path is invalid.  I have tried the following paths to no avail:

/http://servername:80/Reports/AdventureWorks 2008 Sample Reports/Company Sales 2008

/http://servername/Reports/AdventureWorks 2008 Sample Reports/Company Sales 2008

It seems that there is also a Report Viewer webpart that can be used to display native mode reports, but it seems like you install that the same way you install the Integrated mode webpart.  I have a ReportViewerWebPart, but it is the same as the Integrated mode web part.  Can someone point me to the steps to install the Native mode Report Viewer web part?

We are running SharePoint 2007 and SQL Server 2008 SP1.

Thanks in advance!



Where/how to get the 2010 report deisgner and report viewer integrated into a VWD 2010 Express project?


Hi all, I have created a report by using the VB and the Report Viewer. However, the report is not a standard table report, it is actually a printout which turns the data from the form to a printed version. I feed the data from the form to dataset and then the report viewer can display the single record in the form.

Sample code as below: 
r = ds.BCR.NewRow
r("ref_no") = txtRefNo.text
r("description") = txtDesc.text
r("quatity") = txtQuatity.text
Dim rds As Microsoft.Reporting.WinForms.ReportDataSource = New Microsoft.Reporting.WinForms.ReportDataSource
rds.Value = ds.Tables(0)
rds.Name = "DataSet"
frmReport.ReportViewer.LocalReport.ReportEmbeddedResource = "report.rdlc"
frmReport.ReportViewer.LocalReport.ReportPath = "report.rdlc"

Now, I am looking for a solution that can select multiple records in a datagrid and then the report viewer can display all of them in multiple pages (1 record per page).

Is any expert can help?


I have a .rdlc report that works fine on my development machine but when I sent it to my host and look at the report viewer smart tag under choose data sources the dialog box is empty.

Hence the report returns blank with no data.

Looking at the same control smart tag on the dev machine the dialog box has the datasource.

The source code for both report locations is the same which shows the datasource.

I am using vs2008 express and sql 2008 on the host.

any ideas on how I can get the datasource into the datasource box.


Clicking the 'Design a new report' in Report Viewer control has no response. I can click 'Dock in parent container', it responded by docking but when I click 'Design a new report', there is no response. It looks like I did not do something with the Report Viewer control, what did I miss out?

Here are my steps:
- Open Microsoft Visual C# 2008 Express Edition
- The Report Viewer control is not found in Toolbox
- Add the Report Viewer control to the Toolbox

- Note here I check both Microsoft.Reporting.WebForms and Microsoft.Reporting.WinForms but I get only one Report Viewer control in the tool box
- Once the Report Viewer control is added in Toolbox, I drag the Report Viewer control to the Form
- I also create a DataSet in the Form, I drag the Vendors table to the DataSet
- Now when I click the Report Viewer tasks, Design a new report, there is no response

What do I need to do to be able to open the report designer when I click 'Design a new report'??






If I add a reportviwer control to a windows from I get an error message :- 

 Error 4 Value of type 'Pipeline.Microsoft.Reporting.WinForms.ReportViewer' cannot be converted to 'System.Windows.Forms.Control'. D:\Development\BT PMO Pipeline\Pipeline\Pipeline\Project_Report.Designer.vb 38 25 Pipeline.

Error 4 'LocalReport' is not a member of 'Pipeline.Microsoft.Reporting.WinForms.ReportViewer'. D:\Development\BT PMO Pipeline\Pipeline\Pipeline\Project_Report.Designer.vb 30 9 Pipeline


The basic code to load the report is:


'Imports Microsoft.Reportviewer







PrivateSub Project_Report_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)






PrivateSub Project_Report_Load_1(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load







Any ideas much appreciated.




<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure