【问题标题】:How to use same sub-report for n times to display different data如何使用相同的子报表n次显示不同的数据
【发布时间】:2015-03-20 23:16:55
【问题描述】:

我想用同一个子报表来显示不同的数据。

我已尝试创建类列表(针对该子报告)并在子报告处理方法中将每个项目分配给一个子报告,是的,我可以做到,但每个子报告仅显示第一个子报告显示的数据。

但是我已经调试了代码,我发现实际上我为每个子报告发送了不同的数据源,但它们都显示相同的东西,

    private static int index = 0;
    public void LocalReport_SubreportProcessing(object sender, Microsoft.Reporting.WinForms.SubreportProcessingEventArgs e)
    {
        var mainSource =
            (((Microsoft.Reporting.WinForms.LocalReport) sender).DataSources["DataSet"]).Value as BindingSource;

        if (mainSource == null) return;
        switch (e.ReportPath)
        {
            case "FeedbackBar":
                {
                    var List = mainSource.DataSource as List<Classes.Feedback>;
                    if (List != null)
                    {
                        var lst = List[index++].List as B[];

                        e.DataSources.Add(new ReportDataSource("DataSet",  lst));


                    }
                }
                break;
        }
    }

【问题讨论】:

    标签: c# winforms reporting rdlc subreport


    【解决方案1】:

    针对您的问题的临时非专业解决方案是:

    1. 复制您用作数据源的数据集表
    2. 为每个子报表提供不同的表副本作为其数据源

    这对我来说很好。

    【讨论】:

    • 我也面临与 SO 发布相同的问题。请您详细说明您的答案以解决问题。提前致谢。
    猜你喜欢
    • 2021-10-10
    • 1970-01-01
    • 1970-01-01
    • 2015-07-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多