5
votes

I want to use same sub report to display different data.

I have tried to create list of class(for that sub-report) and assign each item to one sub-report at sub-report processing method and yes i could be able to make it but each sub-reports are shown only the data that first sub-report displays.

But i have debugged in code and i found out that actually i am sending different data-source for each sub-report but all of them shows same thing,

    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;
        }
    }
1

1 Answers

0
votes

a temporary not professional solution for your problem is that:

  1. duplicate your dataset table that you use as a datasource
  2. give each subreport a different copy of the table as its datasource

that works fine for me.