title: Sum Gridview column with paging
body: <p>I have a GridView with 100 records and the page size of the grid is 10. Also I need to sum a column from the gridview and show it in a label. I am using the below code in page load event to sum the gridview column and it works as expected.</p>
  
  <pre><code>int sum = 0;
  for (int i = 0; i &lt; gvDetails.Rows.Count; ++i)
  {
     sum += Int.Parse(gvDetails.Rows[i].Cells[4].Value.ToString());
  }
  lblTotal.Text = sum.ToString(); 
  </code></pre>
  
  <p>This code sums the whole value, I mean the sum of 100 records. But I would need a sum only for the 10 records where each page will hold only 10 records and when I do paging and move to each page it has to show only the sum of that respective page.</p>
  
  <p>To make simple I just need to sum the column values I see in the grid and not for all records.</p>
  
  <p>How can this be achieved? Please suggest me.</p>