【问题标题】:.RDLC report doesn't show on ASPX page.RDLC 报告未显示在 ASPX 页面上
【发布时间】:2012-10-09 21:23:13
【问题描述】:

我有一个简单的 .RDLC 报告,它没有显示在它的 ASPX 页面上。我的 ASPX 代码是:

<rsweb:ReportViewer ID="rvReport" runat="server" Height="500px" Width="100%" 
    Font-Names="Verdana" Font-Size="8pt" InteractiveDeviceInfos="(Collection)" 
    WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt">
    <LocalReport ReportPath="reports\rptAttendee.rdlc">
    </LocalReport>
</rsweb:ReportViewer>

在 .cs 文件中,我从我的 Entity Framework 上下文创建一个数据集并将其转换为 ReportData Source,如下所示:

rvReport.LocalReport.DataSources.Clear();
ReportDataSource dataSource = new ReportDataSource("dsAttendees", attendees);
rvReport.LocalReport.DataSources.Add(dataSource);
rvReport.LocalReport.Refresh();

我已经确认数据源是用数据创建的,并且报表视图在添加数据源后注册了数据源。

在 RDLC 文件中,我创建了一个具有相同名称 (dsAttendees) 和完全相同的列/类型的空数据源。当我运行 Web 应用程序时,ASPX 页面不显示报告。检查页面,我确实看到了报表查看器控件,但它是空的;甚至非数据绑定的文本和工具栏都不会出现。

我怀疑问题是 RDLC 文件没有拾取数据源。有没有我遗漏的步骤?

【问题讨论】:

    标签: asp.net .net entity-framework-4 rdlc


    【解决方案1】:

    我不确定,但可能你应该添加这个:

    rvReport.Reset();

    之后

    rvReport.LocalReport.DataSources.Clear();

    【讨论】:

    • 感谢您的建议。我最终改用了一个网格并为它编写了一个导出,因为客户大多只是希望能够导出到 Excel。
    【解决方案2】:

    我最终改用了网格并为网格编写了导出,因为客户大多只是希望能够导出到 Excel。

    【讨论】: