using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microsoft.ApplicationBlocks.Data;
using Microsoft.Reporting.WebForms;
public partial class DrillThroughReport_Parent : System.Web.UI.Page
{
public string thisConnectionString =
ConfigurationManager.ConnectionStrings
["NorthwindConnectionString"].ConnectionString;
public string thatConnectionString =
ConfigurationManager.ConnectionStrings
["NorthwindConnectionString"].ConnectionString;
public SqlParameter[] Level1SearchValue = new SqlParameter[1];
public SqlParameter[] Level2SearchValue = new SqlParameter[1];
protected void RunReportButton_Click(object sender, EventArgs e)
{
ReportViewer1.Visible = true;
SqlConnection thisConnection = new SqlConnection(thisConnectionString);
System.Data.DataSet thisDataSet = new System.Data.DataSet();
thisDataSet = SqlHelper.ExecuteDataset(thisConnection,
"List_Customers_OrderTotal");
ReportDataSource datasource =
new ReportDataSource("DrillThroughDataSet_ListCustomersOrderTotal",
thisDataSet.Tables[0]);
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(datasource);
ReportViewer1.LocalReport.Refresh();
}
protected void ReportViewer1_Drillthrough(object sender,
DrillthroughEventArgs e)
{
ReportParameterInfoCollection DrillThroughValues =
e.Report.GetParameters();
foreach (ReportParameterInfo d in DrillThroughValues)
{
lblParameter.Text = d.Values[0].ToString().Trim();
}
LocalReport localreport = (LocalReport)e.Report;
SqlConnection thisConnection = new SqlConnection(thisConnectionString);
System.Data.DataSet Level1DataSet = new System.Data.DataSet();
Level1SearchValue[0] = new SqlParameter("@OrderID",
lblParameter.Text.Trim());
Level1DataSet = SqlHelper.ExecuteDataset(thisConnection,
"Show_OrderDetails", Level1SearchValue);
ReportDataSource level1datasource = new
ReportDataSource("DrillThroughDataSet_ShowOrderDetails",
Level1DataSet.Tables[0]);
localreport.DataSources.Clear();
localreport.DataSources.Add(level1datasource);
localreport.Refresh();
SqlConnection thatConnection =
new SqlConnection(thatConnectionString);
System.Data.DataSet Level2DataSet = new System.Data.DataSet();
Level2SearchValue[0] =
new SqlParameter("@ProductID", lblParameter.Text);
Level2DataSet = SqlHelper.ExecuteDataset(thisConnection,
"Show_Products", Level2SearchValue);
ReportDataSource level2datasource =
new ReportDataSource("DrillThroughDataSet_ShowProducts",
Level2DataSet.Tables[0]);
localreport.DataSources.Add(level2datasource);
localreport.Refresh();
}
}
http://www.codeproject.com/KB/aspnet/DrillThroughReport.aspx