日期:2014-05-20  浏览次数:20927 次

如何为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();