当前位置: 代码迷 >> .NET报表 >> 怎么为REPORTVIEW动态添加数据源?
  详细解决方案

怎么为REPORTVIEW动态添加数据源?

热度:9652   发布时间:2013-02-25 00:00:00.0
如何为REPORTVIEW动态添加数据源?????
REPORTVIEWER绑定的是objecdatasource,但执行reset的之后原来的绑定没有了,
请问如何重新绑定原来的objectdatasource数据源???

  <rsweb:ReportViewer ID="ReportViewer" runat="server">
  <LocalReport >
  <DataSources>
  <rsweb:ReportDataSource DataSourceId="ODS_Report" Name="JSMonDataSet_VDBasicSingleTable" />
  <rsweb:ReportDataSource DataSourceId="ODS_Report" Name="JSMonDataSet_VDBasicAllTable" />
  </DataSources>
  </LocalReport>
  </rsweb:ReportViewer>

------解决方案--------------------------------------------------------
C# code
 ReportView1.Reset();Dataset ds=new DataSet();            ReportView1.ProcessingMode = ProcessingMode.Local;            Microsoft.Reporting.WebForms.ReportDataSource rds = new ReportDataSource();            rds.Value = ds.Tables[0];            LocalReport r = ReportView1.LocalReport;            r.DataSources.Add(rds);//add datasource
------解决方案--------------------------------------------------------
C# code
            ReportDataSource myRptDS = new ReportDataSource();            myRptDS.DataSourceId = "ObjectDataSource1";            ReportViewer1.LocalReport.DataSources.Add(myRptDS);            ReportViewer1.LocalReport.Refresh();