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

[Solved] Want Sum all rows of perticular column just like aggrigate

1 Answer 56 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rahul
Top achievements
Rank 1
Rahul asked on 05 Aug 2009, 01:46 PM
want to do sum of all the estimated cost but from code behind not using design time .  How to achieve this through code behind . I am trying to do this but it only the sum first five records in grid .


For Each ditim As GridDataItem In dgProposals.MasterTableView.Items
            Dim fieldValue As Double = CDbl(ditim("Estcost").Text.Substring(0))
            txtallproposal.Text = fieldValue + tm
            tm = txtallproposal.Text
        Next



1 Answer, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 06 Aug 2009, 06:43 AM
Hi Rahul,

I suppose you are trying to loop through the entire rows of the Grid through all pages. Here is the sample code which i tried on my end. Give a try with the following approach and see if it works for you.

VB:
 
Protected Sub Button1_Click(ByVal sender As ObjectByVal e As EventArgs) 
       Dim count As Integer = RadGrid1.MasterTableView.PageCount 
     Dim Sum As Integer = 0 
        For i As Integer = 0 To count - 1 
            
           RadGrid1.CurrentPageIndex = i 
           RadGrid1.Rebind() 
            For Each item As GridDataItem In RadGrid1.MasterTableView.Items 
                Dim fieldValue As Integer = Convert.ToInt32(item("Estcost").Text) 
               Sum = fieldValue + Sum 
           Next 
           
           
       Next 
   End Sub 


Regards
Princy

Tags
Grid
Asked by
Rahul
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or