Click here to Skip to main content
15,919,931 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello!

I have a challenge i want to solve.

I have a main report with a list, which contains a subreport. I set the list datasource to a table which generates dates from which the user have selected. Sometimes it is just 1 date, or the user can select a range from which is no limitations. So it can be 5 dates, 10 dates or 100 dates.

So far everything is good an the list gets on row pr date. So when the subreport is inside the list it also generates a subreport pr date.

I am using void LocalReport_SubreportProcessing and it gets fired one time pr date. I have then added logic which then makes a datatable pr date (details for the date) and i am putting this in the

C#
void LocalReport_SubreportProcessing(object sender, Microsoft.Reporting.WinForms.SubreportProcessingEventArgs e)
        {
            var datoer = (from myrows in this.apoLogidose2DoseStudio.DS_Arbeidsplan.AsEnumerable()
                          select myrows.Dato).Distinct();
            DateTime datoSubReport = DateTime.Now;
            int tellenr = 0;
            foreach (var dato in datoer)
            {
                if (tellenr == subReportNr)
                {
                    datoSubReport = dato.Date;
                    break;
                }
                tellenr++;
            }
            var ArbeidsPlanRader = from myrows in this.apoLogidose2DoseStudio.DS_Arbeidsplan.AsEnumerable()
                                   where myrows.Dato.Equals(datoSubReport)
                                   select myrows;

            var a = new _002_Dataset.ApoLogidose2DoseStudio.DS_ArbeidsplanDataTable();
            foreach (var rad in ArbeidsPlanRader)
                a.ImportRow(rad);
            var dt = dtPrDag_(a,datoSubReport);

            e.DataSources.Add(new ReportDataSource("dsRptArbeidsplan",dt as DataTable));
            LocalReport re = sender as LocalReport;

            subReportNr++;
        }



the thing is that all the subreports gets the data from the first firing of subreportproccessing. IE when my logic is serving data from range dates 1 to 15 in a month i have checked the datatable dt that it contains the right data, IE increment the detail date from 1 to 15. But in all subreports it shows data from first date.

I cannot understand this so i have made a fix by making 10 copies of the subreport in the designer. But this limits the max number of dates to 10, i would like this to be completly dynamic, sometimes it is 1 date, sometimes it is 100.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900