-1

我有 4 个报告报告 A、报告 B、报告 C 和报告 D,数据源分别为 dsA、dsB、dsC 和 dsD。

报表 A 是一个主报表,它有一个子报表 B 有一个子报表 C ...

报表 A 使用来自 ReportA 的参数填充 SubreportProcessingEvent 中的数据源 dsB。

我需要一个为报表 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);

我无法弄清楚事件处理程序的第 3 级和第 4 级,任何建议或示例将不胜感激。

谢谢

4

1 回答 1

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>()));
            }
        }
于 2010-07-20T21:05:36.067 回答