如何从ReportViewer DrillThrough事件显示来自ASP.net的详细报告?

时间:2018-10-12 09:15:15

标签: asp.net vb.net reportviewer

我正在尝试获取DrillThrough事件,以在Final_GenralStatment_Total.rdlc报告中显示链接的报告,但是却收到以下错误消息:

“尚未为数据源'DataSet1'提供数据源实例。“

这是我的ASP完整代码页:

Imports Microsoft.Reporting.WebForms

公共类F声明     继承System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

End Sub

Protected Sub ReportViewer1_Drillthrough(sender As Object, e As DrillthroughEventArgs) Handles ReportViewer1.Drillthrough

    Try
        Dim report As LocalReport = CType(e.Report, LocalReport)
        'Dim ds As DataSet = New DataSet()
        Dim dt As DataTable = New DataTable()
        Dim adp As New INV_INDDataSetTableAdapters.Final_GSInterestTotalsTableAdapter
        Dim rds As ReportDataSource = New ReportDataSource("DataSet1", dt)
        ReportViewer1.LocalReport.DataSources.Add(rds)
    Catch ex As Exception
        Throw
    End Try


End Sub

结束班级

以及完整的html页面:

    <%@ Page Title="Final Statement" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="FStatement.aspx.vb" Inherits="Pension.FStatement" %>

<%@ Register Assembly="Microsoft.ReportViewer.WebForms" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    Final Statement
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <table align="center">
        <tr>
            <td>
                <rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana"
                    Font-Size="8pt" InteractiveDeviceInfos="(Collection)"
                    WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt"
                    ZoomMode="PageWidth" AsyncRendering="False" Height="100%"
                    ShowPromptAreaButton="False" ShowZoomControl="False" SizeToReportContent="True"
                    Width="100%" PageCountMode="Actual" BackColor="" ClientIDMode="AutoID" HighlightBackgroundColor="" InternalBorderColor="204, 204, 204" InternalBorderStyle="Solid" InternalBorderWidth="1px" LinkActiveColor="" LinkActiveHoverColor="" LinkDisabledColor="" PrimaryButtonBackgroundColor="" PrimaryButtonForegroundColor="" PrimaryButtonHoverBackgroundColor="" PrimaryButtonHoverForegroundColor="" SecondaryButtonBackgroundColor="" SecondaryButtonForegroundColor="" SecondaryButtonHoverBackgroundColor="" SecondaryButtonHoverForegroundColor="" SplitterBackColor="" ToolbarDividerColor="" ToolbarForegroundColor="" ToolbarForegroundDisabledColor="" ToolbarHoverBackgroundColor="" ToolbarHoverForegroundColor="" ToolBarItemBorderColor="" ToolBarItemBorderStyle="Solid" ToolBarItemBorderWidth="1px" ToolBarItemHoverBackColor="" ToolBarItemPressedBorderColor="51, 102, 153" ToolBarItemPressedBorderStyle="Solid" ToolBarItemPressedBorderWidth="1px" ToolBarItemPressedHoverBackColor="153, 187, 226" ShowBackButton="False" ShowRefreshButton="False">
                    <LocalReport ReportPath="Reports\Final_GenralStatment_Total.rdlc" EnableHyperlinks="True">
                        <DataSources>
                            <rsweb:ReportDataSource DataSourceId="ODSFStatement" Name="DataSet" />
                        </DataSources>
                    </LocalReport>
                </rsweb:ReportViewer>
                <asp:ObjectDataSource ID="ODSFStatement" runat="server" OldValuesParameterFormatString="original_{0}" SelectMethod="GetData" TypeName="Pension.INV_INDDataSetTableAdapters.Final_GenralStatment_TotalTableAdapter"></asp:ObjectDataSource>
            </td>
        </tr>
    </table>
</asp:Content>

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

也许您想尝试一下:

Protected Sub ReportViewer1_Drillthrough(sender As Object, e As Microsoft.Reporting.WebForms.DrillthroughEventArgs) Handles ReportViewer1.Drillthrough

    Dim lclRep As LocalReport = CType(e.Report, LocalReport)

    Dim adp As New Pension.INV_INDDataSetTableAdapters.Final_GSInterestTotalsTableAdapter
    Dim rds As New ReportDataSource("DataSet1", CType(adp.GetData(), DataTable))

    lclRep.DataSources.Add(rds)

End Sub

此外,您可能想看看这个tutorial(不幸的是使用C#)。