最近期间在研究报表,在使用ReportViewer他的时候,指定了rdlc是 系统自动使用了objectdatasource,我现在想如何根据我传的参数,实现不同的集合,在绑定到ReportViewer.
这是目前写的。
后台代码:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//实现参数
ReportParameter[] Rep = new ReportParameter[1];
Rep[0] = new ReportParameter("Dept_id", "0010");
ReportViewer1.LocalReport.SetParameters(Rep);
//Get_Dept()方法返回Datatable
ReportDataSource rep_ds = new ReportDataSource("dept_info", Get_Dept("0010"));
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(rep_ds);
ReportViewer1.LocalReport.Refresh();
}
}
前台:
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<br />
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" Width="100%"
Font-Size="8pt" InteractiveDeviceInfos="(集合)" WaitMessageFont-Names="Verdana"
WaitMessageFont-Size="14pt" ZoomMode="PageWidth">
<LocalReport ReportPath="Report1.rdlc">
<%-- <DataSources>
<rsweb:ReportDataSource DataSourceId="ObjectDataSource1" Name="Dept_Info" />
</DataSources>--%>
</LocalReport>
</rsweb:ReportViewer>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
SelectMethod="GetData"
TypeName="Crystal_Excel.YFV_PMPDataSetTableAdapters.DEPT_INFOTableAdapter">
</asp:ObjectDataSource>
</div>
但是页面运行后,出现的错误