Referencing Data Fields in Variables

Stimulsoft Reports.NET discussion
Post Reply
sbd_jeff
Posts: 27
Joined: Fri Nov 08, 2013 9:39 pm

Referencing Data Fields in Variables

Post by sbd_jeff »

Hi Stimulsoft,
I am attempting to render several fields within label using a variable. I'm attempting this because the variable name will always be the same, versus the label name having a potentially different name.

For example, if I have a datasource "Transactions" with 6 fields:
- Date
- Item
- Item Description
- Cost
- PersonID
- PersonName

I am able to render any number of fields in the group header label using {Transactions.Item} - {Transactions.Description}.
But, If I create a variable of type string using a value type of Expression named "GroupLabel" and set the expression to "Transactions.Item", nothing is shown. If I set the Expression to "Transactions.Item + "B"", only the "B" character is shown.

Is it possible to render data fields within variables?
If so, how?

Thanks.
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Referencing Data Fields in Variables

Post by Alex K. »

Hello,

Can you please send us your report with test data which reproduce the issue for analysis.

Thank you.
sbd_jeff
Posts: 27
Joined: Fri Nov 08, 2013 9:39 pm

Re: Referencing Data Fields in Variables

Post by sbd_jeff »

I am very sorry for the delay in responding.
I have attached an example that illustrates the issue I am having.
There are two columns: Products.UnitPrice and Products.UnitsInStock

If I create a simple text expression with a value of:

Code: Select all

{Products.UnitPrice * Products.UnitsInStock}
I get the expected result (ex. 2 * 3 = 6)

If I create a variable ("TotalValue" in the sample), and attempt to do the same thing:

Code: Select all

Products.UnitPrice * Products.UnitsInStock
I always get 0.

Am I doing something wrong?

Thanks!
Attachments
STIEXAMPLE.zip
MRT with example xsd/xml source
(3.01 KiB) Downloaded 233 times
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Referencing Data Fields in Variables

Post by HighAley »

Hello.

Please, try to set Read Only option of the variable.
Then the expression will be calculated on each request.
You could read more information about this option on the User Manual.

Thank you.
sbd_jeff
Posts: 27
Joined: Fri Nov 08, 2013 9:39 pm

Re: Referencing Data Fields in Variables

Post by sbd_jeff »

Thank you for the clarification Aleksey. Works like a champ!
Andrew
Posts: 4109
Joined: Fri Jun 09, 2006 3:58 am

Re: Referencing Data Fields in Variables

Post by Andrew »

Hello,

Thank you and have a nice day!
Post Reply