views:

700

answers:

1

I am using Winforms Reporting Services (RDLC) to generate a report that has a subreport. My problem is the subreport isn't being filtered by the parent ID.

A simple example of the data model might be a Department which contains Employees.

In the report I want to show all Departments and have a subreport to show the Employees that belong to that Department.

I created a Dataset with two DataTables (Department and Employee). I created a relationship between the two Tables using the DepartmentId column.

In the Form I Fill each table using the appropriate Fill commands. I first fill the Department table then fill the Employee table, i.e. Select * From Deparment and Select * from Employee.

Now for the actual RDLC's: The Department rdlc uses the Deparment datasource and shows information about the department. I dropped a subreport control on this rdlc and set up the properties. I am passing a ReportProperty to the subreport which is the Field!DepartmentId.

In the Employee rdlc I added the Employee datasource and created a filter on Property!DepartmentId.

When I run the report I can cycle through each Department but the subreport does not show. If I remove the Filter from the Employee datasource the subreport shows but displays all of the employees.

In the Form itself I am handling the SubProcessing evert and adding the Employee datasource to the report.

Any ideas on how to link the Subreport data to the parent?

A: 

Pass in the ID from the parent to the sub-report as a parameter and then filter the table in the sub-report based on that parameter value.

MSDN - Configuring Subreports and Drillthrough reports

bdwakefield