다음을 통해 공유


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는 이벤트 사용을 지원하지만 새로운 이벤트 선언은 지원하지 않습니다.

주의

이 이벤트는 드릴스루 항목이 선택될 때 발생합니다. 이 이벤트에 대한 정보는 이벤트를 처리하는 DrillThroughEventHandler 대리자에게 DrillThroughEventArgs 개체를 통해 전달됩니다.

이벤트를 처리하는 방법은 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);

    }
}

참고 항목

참조

ReportViewer 클래스

Microsoft.Reporting.WebForms 네임스페이스