共用方式為


ReportViewer.Drillthrough 事件

發生在選取鑽研項目時。

命名空間:  Microsoft.Reporting.WebForms
組件:  Microsoft.ReportViewer.WebForms (在 Microsoft.ReportViewer.WebForms.dll 中)

語法

'宣告
Public Event Drillthrough As DrillthroughEventHandler
public event DrillthroughEventHandler Drillthrough
public:
 event DrillthroughEventHandler^ Drillthrough {
    void add (DrillthroughEventHandler^ value);
    void remove (DrillthroughEventHandler^ value);
}
member Drillthrough : IEvent<DrillthroughEventHandler,
    DrillthroughEventArgs>
JScript 不支援事件。

備註

這個事件發生在選取鑽研項目時。這個事件的相關資訊會在 DrillThroughEventArgs 物件中傳遞至 DrillThroughEventHandler 委派,由它來處理事件。

如需處理事件的詳細資訊,請參閱使用事件

範例

下列程式碼範例會載入包含一連串鑽研項目的範例報表,並設定事件處理常式來處理鑽研事件。傳遞至鑽研事件處理常式的引數包括鑽研報表物件。事件處理常式會將資料來源加入至這個報表,然後才會在 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 命名空間