放置子报表控件的地方总是报错: 位于 F:\项目\本地项目\Jiao.WebSite\Report\RdlcFiles\Warehouse\ExerciseSubReport_Dateil.rdlc 的子报表“ExerciseSubReport_Dateil”的数据检索失败。有关详细信息,请查看日志文件。 
后台代码:
private DataTable dtDateil;
protected void btnQuery_Click(object sender, EventArgs e)
 {
   srViewer.LocalReport.ReportPath = Server.MapPath("/Report/RdlcFiles/Warehouse/ExerciseSubReport.rdlc");//调试table是有值的,前台那也显示了父报表的数据
   DataTable table = Facade.Common.RDLC.ExerciseSubReport.GetExerciseSubReportData();
//调试dtDateil 是有值的,但是前台就报错
   dtDateil = Facade.Common.RDLC.ExerciseSubReport.GetGetExerciseSubReportDateilData();   srViewer.LocalReport.SubreportProcessing +=
                new SubreportProcessingEventHandler(SubreportProcessingEventHandler);
//ExerciseSubReport与父报表名是一样的
   this.srViewer.LocalReport.DataSources.Add(new ReportDataSource("ExerciseSubReport", table));
   this.srViewer.DataBind();
}/// <summary>
/// 为子报表加数据源
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void SubreportProcessingEventHandler(object sender, SubreportProcessingEventArgs e)
{
//ExerciseSubReport_Dateil与子报表名是一样的
    e.DataSources.Add(new ReportDataSource("ExerciseSubReport_Dateil", dtDateil));
}

解决方案 »

  1.   

    一、我在VS2010中添加报表ExerciseSubReport.rdlc和ExerciseSubReport_Dateil.rdlc分别作为示例的主报表和子报表。
    二、在主报表中拖了子报表控件然后右击子报表属性选择这个子报表指向哪个文件及传递给子报表的参数
    三、在子报表中添加一个参数后台代码就是上面的,但是怎么总是报错呢?
      

  2.   

    SubReport
    参考
      

  3.   

    this.srViewer.LocalReport.DataSources.Add(new ReportDataSource("ExerciseSubReport", table));里面的“ExerciseSubReport”和设计报表的数据源名称是一样的吗
      

  4.   

    右键点RDLC报表的table,,在属性里的常规选项卡里 有数据集名称