Page 1 of 1

Reusing report with different data - dictonary not synched

Posted: Tue May 21, 2013 11:53 am
by Tobias
Why doesn't this work?:

Code: Select all

            var report = new StiReport();

            var data1 = new
            {
                Amount = 10.0m,
            };
            report.Dictionary.Clear();
            report.RegData("Voucher", data1);
            report.Dictionary.Synchronize();
            report.Design();
            report.Print();

            Console.ReadLine();

            var data2 = new
            {
                Amount = 20.0m,
            };
            
            report.Dictionary.Clear();
            report.RegData("Voucher", data2);
            report.Dictionary.Synchronize();
            report.Dictionary.SynchronizeBusinessObjects(100);
            report.Print();
The data of the second printout is still 10.00m instead of 20.00. The form only contains a databand with a single field.

Re: Reusing report with different data - dictonary not synch

Posted: Wed May 22, 2013 6:25 am
by HighAley
Hello.

Please, try to use

Code: Select all

report.Dictionary.Databases.Clear();
instead of

Code: Select all

report.Dictionary.Clear();
Thank you.

Re: Reusing report with different data - dictonary not synch

Posted: Wed May 22, 2013 8:22 am
by Tobias
Unfortunately this doesn't work either. If I call report.Design() before the second report.Print(), then I see the correct value.

Re: Reusing report with different data - dictonary not synch

Posted: Wed May 22, 2013 8:33 am
by Tobias
Argh - the easy solution is to do a report.Render() before doing a report.Print(). It seems Reports.Net doesn't force a re-rendering automatically when new data gets registered.

Re: Reusing report with different data - dictonary not synch

Posted: Thu May 23, 2013 12:35 pm
by HighAley
Hello.

First time the Render() is called automatically.
But on second calling of Print() method it isn't rendered because already is.
So if you change data source after report was rendered then you should call Render() method or just set the report.IsRendered property to false.

Thank you.