This is a migrated thread and some comments may be shown as answers.

Recalculate subtotal when field value changes

1 Answer 52 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Deepak Shakya
Top achievements
Rank 1
Deepak Shakya asked on 11 May 2011, 01:37 AM
Hi,

Situation:

I have populated the fields using a datasource. One of the fields has null values. So, I have used a ItemDataBound event to populate the values from a list of values in Hashtable when the value is null. It populates alright.

Problem:

The subtotal in the GroupFooter section still gives the sum of the values which were NOT NULL initially.

Code:
private void fldAverageAnnualNLoadDataTextBox_ItemDataBound(object sender, EventArgs e)
        {
            Telerik.Reporting.Processing.TextBox tbAnnualLoad = (Telerik.Reporting.Processing.TextBox)sender;
            if (currentScenario == "Base-case")
            {
                if (!baseCaseValues.ContainsKey(currentCatchment))
                {
                    baseCaseValues.Add(currentCatchment, tbAnnualLoad.Value);
                }               
            }
 
            if (tbAnnualLoad.Value == null && currentScenario != "Base-case")
            {
                tbAnnualLoad.Value = string.Format("{0:0.0}", baseCaseValues[currentCatchment]);
            }
        }
 
Any help is highly appreciated.

1 Answer, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 16 May 2011, 02:54 PM
Hi Deepak Shakya,

Telerik Reporting is highly oriented in using expressions and we believe this is the more flexible and right approach to handle calculations. Try avoiding the usage of code behind / event handling as much as possible. So instead of handling ItemDataBound event in order to check for the item value, you can use the built-in IsNull function both for the textbox that shows the actual value as well as for the textbox that aggregated over that field.

Regards,
Steve
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
Deepak Shakya
Top achievements
Rank 1
Answers by
Steve
Telerik team
Share this question
or