次の方法で共有


ReportViewer.Drillthrough イベント

Occurs when a drillthrough item is selected.

名前空間: Microsoft.Reporting.WebForms
アセンブリ: Microsoft.ReportViewer.WebForms (microsoft.reportviewer.webforms.dll 内)

構文

'宣言
'使用

解説

This event occurs when a drillthrough item is selected. Information about this event is passed in a DrillThroughEventArgs object to the DrillThroughEventHandler delegate, which handles the event.

For more information about handling events, see イベントの利用.

The following code example loads a sample report containing a series of drillthrough items and sets up an event handler to handle the drillthrough events. The arguments passed to the drillthrough event handler include a drillthrough report object. The event handler adds a data source to this report before the drillthrough report is rendered in the ReportViewer control.

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_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        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_Load(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 クラス
ReportViewer メンバ
Microsoft.Reporting.WebForms 名前空間