2010-02-11 34 views
-1

我有4份报告报告A,报告B,报告C和报告D分别与数据源dsA,dsB,dsC和dsD。ReportViewer嵌套SubReport

报告A是具有子报表B中的主报告具有子报表ç...

报告中的填充数据源DSB与来自ReportA参数的SubreportProcessingEvent。

我需要这是在申报书B的每一行,让我传递的参数,从申报书B触发的事件,并填写报告的C和C参数报告d ....在SubreportProcessingEventArg

代码

SearchValue = new SqlParameter[2]; 
    SqlConnection thisConnection = new SqlConnection(thisConnectionString); 
    DataSet thisDataSet = new DataSet(); 
    SearchValue[0] = new SqlParameter("@TPlanId", e.Parameters[1].Values[0]); 
    SearchValue[1] = new SqlParameter("@ProblemId", e.Parameters[0].Values[0]); 

    thisDataSet = SqlHelper.ExecuteDataset(thisConnection, "Proc_TP_Goal", SearchValue); 

    /* Associate thisDataSet (now loaded with the stored procedure result) with the ReportViewer datasource */ 
    ReportDataSource datasource = new ReportDataSource("Goal_Proc_TP_Goal", thisDataSet.Tables[0]); 
    e.DataSources.Add(datasource); 

我无法弄清事件处理程序的第三和第四级任何建议或例子将不胜感激。

感谢

回答

1

我这样做,我必须在通过报表的行的子子报表的参数。我希望你明白,如果不让我知道,我会发布一个源代码。

if ("RendicionDetalleCodigosReporte".Equals(e.ReportPath)) 
     { 
      if (data != null) 
      { 
       RendicionDetalleData detalle = new RendicionDetalleData(); 
       detalle.row = 0; 
       int row = Convert.ToInt32(e.Parameters[0].Values[0]); 
       foreach (var det in data.Detalles) 
       { 
        if (det.row.Equals(row)) 
        { 
         detalle = det; 
         break; 
        } 

       } 

       if (detalle.row == 0) 
       { 
        e.DataSources.Add(new ReportDataSource("RendicionDetalleCodigo", new List<RendicionDetalleCodigosData>())); 
       } 
       else 
       { 
        e.DataSources.Add(new ReportDataSource("RendicionDetalleCodigo", detalle.Codigos)); 
       } 
      } 
      else 
      { 
       e.DataSources.Add(new ReportDataSource("RendicionDetalleCodigo", new List<RendicionDetalleCodigosData>())); 
      } 
     } 
     else 
     { 
      if (data != null) 
      { 
       e.DataSources.Add(new ReportDataSource("RendicionDetalle", data.Detalles)); 

      } 
      else 
      { 
       e.DataSources.Add(new ReportDataSource("RendicionDetalle", new List<RendicionDetalleData>())); 
      } 
     } 
+1

感谢发布!这是前一段时间我已经发布,我已经实现了这方面的工作,如果您发布源代码以供将来参考,这将是很好的。 – zeusmos

+0

@vinod您实施了哪种解决方法? – Tommassiov