Reusing report with different data - dictonary not synched

Stimulsoft Reports.NET discussion
Post Reply
Tobias
Posts: 104
Joined: Mon Nov 24, 2008 8:44 am

Reusing report with different data - dictonary not synched

Post 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.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Reusing report with different data - dictonary not synch

Post by HighAley »

Hello.

Please, try to use

Code: Select all

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

Code: Select all

report.Dictionary.Clear();
Thank you.
Tobias
Posts: 104
Joined: Mon Nov 24, 2008 8:44 am

Re: Reusing report with different data - dictonary not synch

Post by Tobias »

Unfortunately this doesn't work either. If I call report.Design() before the second report.Print(), then I see the correct value.
Tobias
Posts: 104
Joined: Mon Nov 24, 2008 8:44 am

Re: Reusing report with different data - dictonary not synch

Post 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.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Reusing report with different data - dictonary not synch

Post 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.
Post Reply