Continueing with my earlier post on the RDLC and Drill Through reports, in this article we'll be checking the second method of passing parameters through filtering of report items.

The steps till completing the design of the reports are still going to remain the same. So please refer,

 http://blogs.msdn.com/selvar/archive/2010/03/03/dynamically-passing-parameter-to-drillthrough-report-in-rdlc-part-1.aspx

We'll be doing the code change only in the DrillThrough event handler code. Look at the below lines of code.

protected void ReportViewer1_Drillthrough(object sender, Microsoft.Reporting.WebForms.DrillthroughEventArgs e)

{

//Get the instance of the Target report, in our case the JumpFilterReport.rdlc.

LocalReport report = (LocalReport)e.Report;

//Create the instance for the EmpDeptHistoryDataSet which will

//hold the EmployeeDepartmentHistory table details.

EmpDeptHistoryDataSet ds = new EmpDeptHistoryDataSet();

 

//Making sure the dataset doesn't contain any constraints.

ds.EnforceConstraints = false;

//Create a SQL Connection to the AdventureWorks database using Windows Authentication.

using (SqlConnection sqlconn = new SqlConnection("Data Source=.;Initial Catalog=Adventureworks;Integrated Security=SSPI"))

{

//Building the SQL query.

SqlDataAdapter adap = new SqlDataAdapter("select EmployeeID, DepartmentID, ShiftID from HumanResources.EmployeeDepartmentHistory", sqlconn);

//Executing the QUERY and filling the dataset with the Resultset.

adap.Fill(ds,"EmployeeDepartmentHistory");

}

report.DataSources.Add(new ReportDataSource("EmpDeptHistoryDataSet_EmployeeDepartmentHistory", ds.EmployeeDepartmentHistory));

}

Finally, run the project, You'll see MainReport rendering in the ReportViewer control.

Click on any of the EmployeeID and you'll see the JumpFilterReport displayed for the selected EmployeeID.

If you carefully look at the difference between what we saw in the Part - 1 and now is, the QUERY that is executed in this sample is an unfiltered one. The filtering is done at the report level. If you're a person who is worried about the performance, then my recommendation would be to follow Part - 1.

That pretty much concludes our sample. I’ve uploaded the sample please change the connections string values in the web.config and in the Default.aspx.cs files and try executing the report. Happy programming!!.

HTH!

Selva.

[All the Posts are AS-IS with no warranties]