Version

Retrieve the Result of a Summary

You can retrieve a SummaryResult object by indexing into a SummaryResults collection off a Records collection in xamDataPresenter™. The Value property of the SummaryResult object returns the result of the summary. You may need to cast the Value property to the correct data type before using it in your application logic.

The built-in summary calculators will return the following data types:

Summary Calculator Data Type

Sum

Decimal

Average

Decimal

Count

Integer

Minimum

Data Type of the Field

Maximum

Data Type of the Field

The following example code demonstrates how to retrieve the result of a summary.

In Visual Basic:

...
'The code below assumes that you have at least one summary in the root-level field layout.
Try
    Dim val As Object = Me.xamDataPresenter1.Records.SummaryResults(0).Value
    Dim summaryValue As Decimal = Convert.ToDecimal(val)
    MessageBox.Show(String.Format("First summary value is {0}", summaryValue))
Catch
    'fail silently
End Try
...

In C#:

...
'The code below assumes that you have at least one summary in the root-level field layout.
try
{
    object val = this.xamDataPresenter1.Records.SummaryResults[0].Value;
    decimal summaryValue = Convert.ToDecimal(val);
    MessageBox.Show(string.Format("First summary value is {0}", summaryValue));
}
catch
{
    //fail silently
}
...