using System;
using System.Data;
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 System.Data.SqlClient;
using Microsoft.ApplicationBlocks.Data;
using Microsoft.Reporting.WebForms;
public partial class DrillThroughReport_Parent : System.Web.UI.Page
{
public SqlParameter[] Level1SearchValue = new SqlParameter[1];
public SqlParameter[] Level2SearchValue = new SqlParameter[1];
public string thisConnectionString =
ConfigurationManager.ConnectionStrings
["NorthwindConnectionString"].ConnectionString;
DrillThroughDataSet ds = new DrillThroughDataSet();
protected void Page_Load(object sender, EventArgs e)
{
}
protected void ReportViewer1_Drillthrough1(object sender, DrillthroughEventArgs e)
{
//Get OrderID that was clicked by
//user via e.Report.GetParameters()
ReportParameterInfoCollection DrillThroughValues =
e.Report.GetParameters();
//This is just to show you how to iterate
//through the collection if you have
//multiple parameters values instead of a single parameter value.
//To process multiple parameters values,
//concatenate d.Values[0] into a string with a delimiter.
//Use the Split() method to separate values
//into an array. Assign indivdual array element to
//corresponding parameter array element.
foreach (ReportParameterInfo d in DrillThroughValues)
{
lblParameter.Text = d.Values[0].ToString().Trim();
}
LocalReport localreport = (LocalReport)e.Report;
//Fill dataset for Level1.rdlc
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_Show_OrderDetails",
Level1DataSet.Tables[0]);
localreport.DataSources.Clear();
localreport.DataSources.Add(level1datasource);
localreport.Refresh();
}
protected void Button1_Click(object sender, EventArgs e)
{
ReportViewer1.Visible = true;
SqlConnection thisConnection = new SqlConnection(thisConnectionString);
System.Data.DataSet thisDataSet = new System.Data.DataSet();
//Run the stored procedure to fill dataset for Parent.rdlc
thisDataSet = SqlHelper.ExecuteDataset(thisConnection,
"List_Customers_OrderTotal");
//和设计时表名一致
//Assign dataset to report datasource
//datasource的名称即DrillThroughDataSet_List_Customers_OrderTotal要和设计报表时的数据源名称一致
ReportDataSource datasource =
new ReportDataSource("DrillThroughDataSet_List_Customers_OrderTotal",
thisDataSet.Tables[0]);
//Assign datasource to reportviewer control
ReportViewer1.LocalReport.ReportPath = "parent.rdlc";
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(datasource);
ReportViewer1.LocalReport.Refresh();
}
}