我ReportViewer
在 ASCX 中有一个控件,如下所示:
<rsweb:ReportViewer
Height="100%"
Width="100%"
ID="ReportViewer1"
runat="server"
AsyncRendering="False"
Font-Names="Verdana"
Font-Size="8pt"
WaitMessageFont-Names="Verdana"
WaitMessageFont-Size="14pt"
OnDataBinding="ReportViewer1_DataBinding"
OnDisposed="ReportViewer1_Disposed"
OnInit="ReportViewer1_Init"
OnLoad="ReportViewer1_Load"
OnReportError="ReportViewer1_ReportError">
</rsweb:ReportViewer>
在包含 ASCX 的页面加载中:
ReportViewer1.LocalReport.DataSources.Clear();
int draftID = Convert.ToInt32(Session["DraftID"]);
MyTableAdapter adapter = new MyTableAdapter();
var table= adapter.GetData(draftID);
ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Reports/MyReport.rdlc");
var reportDataSource = new Microsoft.Reporting.WebForms.ReportDataSource("MyDataSource", (System.Data.DataTable)table);
ReportViewer1.LocalReport.DataSources.Add(reportDataSource);
ReportViewer1.LocalReport.Refresh();
我有理由确定我已经正确设置了网络配置。在compilation
标签中:
<buildProviders>
<add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
</buildProviders>
在handlers
标签中(为简洁起见,只是处理程序):
<add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
生成的适配器中的表格被填满,乍一看,看起来是正确的。我在列出的事件上设置了断点,它将被初始化、加载,但从不绑定,这让我相信我错过了一些明显的东西。
有任何想法吗?