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

Getting Values From Grid Footer Aggregate Totals

1 Answer 253 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Shawn
Top achievements
Rank 1
Shawn asked on 29 May 2009, 04:55 PM
I have a page that displays 4 different grids all with footer totals.  I want a way to take these totals and compute them so I can place them in a final total label on the page.  Here is an example of one of the grid total columns:
 <telerik:GridBoundColumn DataField="TotalPrice" DataType="System.Decimal"  
            HeaderText="Total" SortExpression="TotalPrice" UniqueName="TotalPrice" DataFormatString="{0:c}" Aggregate="Sum" FooterText="Total Due : " ReadOnly="True"
<FooterStyle HorizontalAlign="Center" Font-Bold="True" CssClass="SoldFooter"></FooterStyle> 
            <HeaderStyle HorizontalAlign="Center" /> 
            <ItemStyle HorizontalAlign="Center" /> 
        </telerik:GridBoundColumn> 

All four grids have these columns. 2 of the grids are called "TotalPrice" and the other 2 are "TotalCost"  I need to subtract the totals of the cost from the totals of the price and display the result in a label.  If it is positive then I want it in Green and Negative in red.

First things first though, how do I get all of these values from the grids so that I can manipulate the values.  Do I do it in the Page "Loan_Complete" event....?  And how do I reference the aggregate footer column?

Thanks!


1 Answer, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 01 Jun 2009, 10:29 AM
Hello Shawn,

You can get the aggregate value for a certain column in the ItemDataBound event as follows:

    protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)  
    {  
        if (e.Item is GridFooterItem)  
        {  
            GridFooterItem item = e.Item as GridFooterItem;  
 
            double value = Double.Parse(item["TotalPrice"].Text.Split(':')[1].Trim());  
        }  
    } 

I hope this helps.

Best Regards,
Tsvetoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Shawn
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Share this question
or