Thursday, October 19, 2006 9:42 AM
by
bsandeman
XPath Calculations
Another handy thing to know
String xpath =
"sum(/ns1:Invoice/ns1:InvoiceDetail/ns1:Lines/ns1:Line/ns1:AmountMatched)";
int amountMatched =
Int32.Parse(this.MainDataSource.CreateNavigator().Evaluate(xpath, this.NamespaceManager).ToString);
The above code shows how to evaluate any valid xpath expression so that you can calculate values through code-behind, very useful. As it currently looks like default values/formulas are only calculated when a field value changes and not at form load.
It is worth noting that you can use the Evaluate method on any XPathNavigator object