ReportViewer.Drillthrough 事件
当选择了钻取项时发生。
命名空间: Microsoft.Reporting.WebForms
程序集: Microsoft.ReportViewer.WebForms(在 Microsoft.ReportViewer.WebForms.dll 中)
语法
声明
Public Event Drillthrough As DrillthroughEventHandler
用法
Dim instance As ReportViewer
Dim handler As DrillthroughEventHandler
AddHandler instance.Drillthrough, handler
public event DrillthroughEventHandler Drillthrough
public:
event DrillthroughEventHandler^ Drillthrough {
void add (DrillthroughEventHandler^ value);
void remove (DrillthroughEventHandler^ value);
}
member Drillthrough : IEvent<DrillthroughEventHandler,
DrillthroughEventArgs>
JScript 支持使用事件,但不支持声明新事件。
注释
当选择了钻取项时会发生此事件。有关此事件的信息通过 DrillThroughEventArgs 对象传递到处理此事件的 DrillThroughEventHandler 委托。
有关处理事件的更多信息,请参见Consuming Events。
示例
下面的代码示例加载包含一系列钻取项的示例报表,并设置一个事件处理程序来处理钻取事件。传递到钻取事件处理程序的参数包括钻取报表对象。在**“ReportViewer”**控件中呈现钻取报表之前,事件处理程序会先向此报表添加数据源。
Imports System.Data
Imports Microsoft.Reporting.WebForms
Partial Class _Default
Inherits System.Web.UI.Page
Private Function LoadEmployeesData() As DataTable
Dim dataSet As New DataSet()
dataSet.ReadXml("c:\My Reports\employees.xml")
LoadEmployeesData = dataSet.Tables(0)
End Function
Private Function LoadDepartmentsData()
Dim dataSet As New DataSet()
dataSet.ReadXml("c:\My Reports\departments.xml")
LoadDepartmentsData = dataSet.Tables(0)
End Function
Public Sub DemoDrillthroughEventHandler(ByVal sender As Object, ByVal e As DrillthroughEventArgs)
Dim localReport = e.Report
localReport.DataSources.Add(New ReportDataSource("Employees", LoadEmployeesData()))
End Sub
Private Sub Form1_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
If (Not IsPostBack) Then
' Set RDL file.
ReportViewer1.LocalReport.ReportPath = "c:\My Reports\Departments.rdlc"
' Supply a DataTable corresponding to each report data source.
Dim myReportDataSource = New ReportDataSource("Departments", LoadDepartmentsData())
ReportViewer1.LocalReport.DataSources.Add(myReportDataSource)
End If
'Add a handler for drillthrough.
AddHandler ReportViewer1.Drillthrough, AddressOf DemoDrillthroughEventHandler
End Sub
End Class
using System;
using System.Data;
using System.Configuration;
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.Reporting.WebForms;
public partial class _Default : System.Web.UI.Page
{
private DataTable LoadEmployeesData()
{
DataSet dataSet = new DataSet();
dataSet.ReadXml(@"c:\My Reports\employees.xml");
return dataSet.Tables[0];
}
private DataTable LoadDepartmentsData()
{
DataSet dataSet = new DataSet();
dataSet.ReadXml(@"c:\My Reports\departments.xml");
return dataSet.Tables[0];
}
void DemoDrillthroughEventHandler(object sender, DrillthroughEventArgs e)
{
LocalReport localReport = (LocalReport)e.Report;
localReport.DataSources.Add(new ReportDataSource("Employees",
LoadEmployeesData()));
}
protected void Page_Init(object sender, EventArgs e)
{
if (!IsPostBack)
{
// On initial page load
ReportViewer1.LocalReport.ReportPath = @"c:\My Reports\Departments.rdlc";
// Supply a DataTable corresponding to each report data source.
ReportViewer1.LocalReport.DataSources.Add(
new ReportDataSource("Departments", LoadDepartmentsData()));
}
// Add the handler for drillthrough.
ReportViewer1.Drillthrough += new DrillthroughEventHandler(DemoDrillthroughEventHandler);
}
}