我遇到了.aspx
页面中嵌入的 ReportViewer 对象的奇怪行为。
在与参考文献斗争之后,我达到了一个稳定的配置,这个配置很好地描述了Web.config
:
<?xml version="1.0"?>
<configuration>
<system.webServer>
<handlers>
<remove name="ReportViewerWebControlHandler" />
<add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
</handlers>
</system.webServer>
</configuration>
<system.web>
<compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="Microsoft.ReportViewer.WebForms, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91" />
<add assembly="Microsoft.ReportViewer.Common, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845DCD8080CC91" />
</assemblies>
<buildProviders>
<add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.WebForms, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
</buildProviders>
</compilation>
<httpHandlers>
<add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" validate="false" />
</httpHandlers>
</system.web>
在.aspx页面中,通过此指令引用了ReportViewer:
<%@ Register Assembly="Microsoft.ReportViewer.WebForms" Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
然后以这种方式在页面中实例化:
<rsweb:ReportViewer ID="_rptData" runat="server" Width="100%">
</rsweb:ReportViewer>
其他所有内容都是代码隐藏的(在c#中):
_rptData.Visible = true;
_rptData.LocalReport.ReportPath = Server.MapPath(@"rptData.rdlc");
_rptData.LocalReport.EnableHyperlinks = true;
if (_rptData.LocalReport.DataSources.Count > 0)
_rptData.LocalReport.DataSources.Clear();
_rptData.LocalReport.DataSources.Add(new Microsoft.Reporting.WebForms.ReportDataSource("DataSet1", _dt));
_rptData.DataBind();
出于某种原因,当我显示页面时,报表的工具栏以这种方式呈现:
在同一个网站中,只是在不同的文件夹中,我有类似的页面显示带有“正确”收费栏的报告:
问题出在哪里?