The value for totalPriceTextBox and totalCostTextBox are from datasource fields.
The value for textBox1 is defined as:
=Fields.TotalPrice - Fields.TotalCost
The value for textBox2 is defined as:
=textBox1.Value / Fields.TotalCost * 100
When I view this report in the Preview tab, totalPriceTextBox, totalCostTextBox are textBox1 are successfully displayed. However I get the error as displayed below for textbox2:
An error has occurred while processing Textbox 'textbox2':
The expression contains object 'textbox1' that is not defined in the current context
Can anyone help me on this? Thank you.
8 Answers, 1 is accepted
In expressions you can't directly reference other report items. Instead our suggestion is to update your expression as shown in the following example:
=(Fields.TotalPrice - Fields.TotalCost)/ Fields.TotalCost * 100
Peter
the Telerik team
HAPPY WITH REPORTING? Do you feel that it is fantastic? Or easy to use? Or better than Crystal Reports? Tell the world, and help fellow developers! Write a short review about Telerik Reporting and Telerik Report Designer in Visual Studio Gallery today!
For your info, the example that I gave on my first post was the simplified version of my report. In my actual report, there are some textboxes with expressions like this:
=SUM(Fields.TotalPrice - Fields.TotalCost)
I also have some textboxes where I need to calculate this:
=SUM(Fields.TotalPrice - Fields.TotalCost) / SUM(Fields.TotalPrice) * 100
If I just use this expression (
=SUM(Fields.TotalPrice - Fields.TotalCost) / SUM(Fields.TotalPrice) * 100
), I will need to calculate SUM(Fields.TotalPrice - Fields.TotalCost)
and SUM(Fields.TotalPrice)
again for each textbox. Let's say I have many rows of data, won't this affect the time taken to display the report?The reporting engine should quickly handle such expressions. Our suggestion is to make some tests to check what is the performance impact of this expression. Still if you require to access another processing report item value you can utilize the following user function:
public
static
object
GetProcessingItemValue(
Processing.ReportItem currentReportItem,
string
targetReportItemName)
{
var targetReportItem = Processing.ElementTreeHelper.GetChildByName(
currentReportItem.ParentElement,
targetReportItemName)
as
Processing.TextBox;
return
targetReportItem.Value;
}
Regards,
Peter
the Telerik team
HAPPY WITH REPORTING? Do you feel that it is fantastic? Or easy to use? Or better than Crystal Reports? Tell the world, and help fellow developers! Write a short review about Telerik Reporting and Telerik Report Designer in Visual Studio Gallery today!
I also have a simular problem.....
I need to filter a table on a report dynamically with the value of a textbox on the same report
Could you please tell me which parameters i need to use to call
GetProcessingItemValue( Processing.ReportItem currentReportItem, string targetReportItemName)
Thanks Paul
The approach suggested by my colleague won't work in every scenario, as he has described after the provided code snippet. Since the TextBox.Value in question is probably coming from a data source, it is best to create a user function, or modify your data source to return a calculated field, which returns the same value and can be used in the table Filtering expression.
Regards,
Nasko
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
TextBox1=fields.Name
Textbox2=IIf(IsNull(Fields.Registant,0)=0,0,CDbl(Fields.Registant)/ exec("Report1",CDbl(Sum(Fields.Registant))))
and i want a textbox on footer which contains the value like
TextBox3=Sum(Textbox2) i have tried something like
Sum(IIf(IsNull(Fields.Registant,0)=0,0,CDbl(Fields.Registant)/ exec("Report1",CDbl(Sum(Fields.Registant)))))
but did not work..
Hi telerik team,
I have two text boxes in my report. First textbox have hardcoded value 5. Now i need to get the value of the first textbox and do some calculation in second textbox. In this situation what can i do? Please help me. Thanks.