Data binding in the report

Stimulsoft Reports.WPF discussion
EdQ
Posts: 7
Joined: Wed Apr 18, 2018 8:03 am

Data binding in the report

Post by EdQ »

Hello,
In the report I have a Text field which is bound to the Variable Var1. When I run the report the default value of Var1 is shown in the Text field as expected. When I change the value of Var1 in a Click event Var1=”12345” the value of Text filed is not changed to “12345”. It still shows the default value. How can I solve this problem? Thank you.
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Re: Data binding in the report

Post by Edward »

Hi Ed,

Sorry, could not reproduce the problem. Have you tried to set the variable's value as per the following sample project?

https://www.stimulsoft.com/en/samples/w ... es-in-code

Thank you,
Edward
EdQ
Posts: 7
Joined: Wed Apr 18, 2018 8:03 am

Re: Data binding in the report

Post by EdQ »

Hi Edward,
Not that way like in the link. I am using only the Designer for WPF as following.
1. New empty report
2. Create a new variable and give it the name Temp and assign it a default value.
3. I drag a Text component on the Report and bind it to the Temp variable
4. Preview the report and the Text component shows the default value of the variable Temp
5. I create a Click event for the page and write the following code in the event editor
Temp = ”Hello World”;

I expect thatthe text “Hello World” to be shown in the Text component but it still shows the default value.

Thank You
Lech Kulikowski
Posts: 6245
Joined: Tue Mar 20, 2018 5:34 am

Re: Data binding in the report

Post by Lech Kulikowski »

Hello

In this case, you should rerender report with new values:

Variable1 = "321";
this.Render(false);

Thank you.
EdQ
Posts: 7
Joined: Wed Apr 18, 2018 8:03 am

Re: Data binding in the report

Post by EdQ »

It works.

Thank You very much!
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Re: Data binding in the report

Post by Edward »

Hi Ed,

Thank you very much for explaining your task in greater detail and to confirm the Lech's advice has solved the problem.

Please let us know if you need any help.

Thank you,
Edward
EdQ
Posts: 7
Joined: Wed Apr 18, 2018 8:03 am

Re: Data binding in the report

Post by EdQ »

Hi Esward,
I have another question. First what I am doing.
1. Create new report in Designer
2. Create a new Data source called Person. Person is a class in my Visual studio project.
public class Person
{
public string Name { get; set; }
public string Surname { get; set; }
}
3. In the Visual studio project I create a List<Prerson> like _person = new List<Person>(); and register the data to the report
report = new StiReport();
report.RegData("Person", _persons);
report.Load("Report.mrt");

4. In the designer I drag the Data source on the page and a table is created automatically.
5. The click on preview shows the report. The table shows the data, 20 rows, as expected.

Now in my visual studio project I change the Name and Surname of a person like _person[4].Name=”name1”;
_person[4].Surname=”surname1”;
I expect to see these changes in the report, but the report shows always the old values. I tried the report.Render() but no success. What can I do in this case?
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Re: Data binding in the report

Post by Edward »

Hi Ed,

Thank you for explanation of the problem in detail.

Please check the following topics:
viewtopic.php?f=8&t=846

And more information on Business Objects registration please check in the following documentation page:
https://www.stimulsoft.com/en/documenta ... ionary.htm

If you clear the Dictionary and re-register your data, the report data will refresh itself.

Also there is a way to replace the already registered data as it was suggested in the following topic:

viewtopic.php?f=13&t=37064

Thank you,
Edward
EdQ
Posts: 7
Joined: Wed Apr 18, 2018 8:03 am

Re: Data binding in the report

Post by EdQ »

Hi Edward,

it worked,

Thank You very much.
EdQ
Posts: 7
Joined: Wed Apr 18, 2018 8:03 am

Re: Data binding in the report

Post by EdQ »

Hi Edward,

another point. To avoid rendering delay for a huge amount of data, the report shows the data part by part. It works very well.
Now, when the user save the report as PDF or other format, the generated PDF shows the rows of data that the report has in that moment.
What I like to do is this. When the user click on save as, I clear first the actual data of the report and register the all huge data in the report. In this way I hope that the PDF shows all the data.
How can I do that?

Thank you in advance
Post Reply