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

rdlc报表中ReportView动态绑定rdlc文件的问题
我现在用rdlc报表做一个项目,建立了两个rdlc文件,分别是ReportGeneralSingleSt.rdlc,ReportTypicalSingleSt.rdlc,一个ReportView,数据源DataInq中两个表:DTGeneralInqSingleSt,DTTypicalInq。
我想实现下述目的:
  一个ReportView动态绑定的绑定两个rdlc文件,按照我需要的时机,分别显示这两个rdlc文件中的表。如果ReportView 选择任务,选择报表中不同的rdlc文件是可以的,但是这样只是静态的显示表,我写的动态改变绑定的报表的代码如下:
如果没有把注释掉的代码加上的话,当我单击动态改变绑定的按钮后,根本没有反应,如果加上的话,则会出现“尚未为数据源“DataSetInq_DTTypicalInq”提供数据源实例“的错误,
请问这是怎么回事,怎么才能实现我的目的?
谢谢

reportViewerInq.LocalReport.ReportPath = applicationPath + @"\Reporting\ReportTypicalSingleSt.rdlc";
  reportViewerInq.LocalReport.DataSources.Clear();
  reportViewerInq.LocalReport.DataSources.Add(new ReportDataSource("DTTypicalInq", dataSetInq.Tables["DTTypicalInq"]));
  reportViewerInq.LocalReport.Refresh();
   
  // dataSetInq.DTTypicalInq.AddDTTypicalInqRow("1", "1.0", "1.0", "1.0", //"1.0", "2.0", "1.0", "0.0");
  // DTTypicalInqBindingSource.DataSource = dataSetInq;//生成的BindingSource
  //reportViewerInq.SetDisplayMode(DisplayMode.PrintLayout);
  //reportViewerInq.RefreshReport();
  // reportViewerInq.ZoomMode = ZoomMode.Percent;
//reportViewerInq.ZoomPercent = 100;


------解决方案--------------------
尚未为数据源“DataSetInq_DTTypicalInq”提供数据源实例, 你确定有提供相应的数据给RDLC使用, 前段时间整理了一些RDLC开发使用文章, lz可以先看看, 希望对你有帮助
------解决方案--------------------
使用公式啊
=IIf(RowNumber(Nothing) Mod 2) =0,"red","yellow")

奇行显示黄色
偶行显示红色