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

How to get aggregate values?

2 Answers 70 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Albert
Top achievements
Rank 1
Albert asked on 26 Nov 2008, 03:14 AM
Like the sum, count, max,  etc. of every column, how can I access this values coz I need them for something else.
Thanks

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 26 Nov 2008, 04:04 AM
Hello Albert,

You can access the aggregate values for a column, in the footer of a grid as shown below:
aspx:
<telerik:GridBoundColumn Aggregate="Count" DataField="ProductName" UniqueName="ProductName" HeaderText="ProductName"
</telerik:GridBoundColumn> 
             

cs:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridFooterItem) 
        { 
            GridFooterItem footer = (GridFooterItem)e.Item; 
            string strtxt = footer["ProductName"].Text; 
            string[] arr = strtxt.Split(':'); 
            string count = arr[1].ToString(); 
        } 
    } 

Also set the ShowFooter property of the grid to true.

Thanks
Princy.
0
Albert
Top achievements
Rank 1
answered on 26 Nov 2008, 05:17 AM
Thanks. But what if I need to get two aggregate values at the same time of one column? Like Min and Max. Can it be done on just one column without using another column and just hiding it?
Tags
Grid
Asked by
Albert
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Albert
Top achievements
Rank 1
Share this question
or