title: Sum the rows in Gridview
body: <p>I want to sum up two columns in the gridview and show the total in the labels. I have paging enabled in the gridview.</p>
  
  <p>Using this code I sum the totals of two columns, however, the total is for the selected page only.</p>
  
  <p>How can I do a <strong>grand total</strong> to sum all the rows for selected columns from all the pages?</p>
  
  <pre><code>    decimal priceTotal = 0;
      int totalMinutes = 0;
      protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
      {
          if (e.Row.RowType == DataControlRowType.DataRow)
          {
              priceTotal += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem, "Total"));
              totalMinutes += Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "Duration"));
          }
          lblTotalPrice.Text = "Total Cost: $"+ priceTotal.ToString();
          lblTotalMinutes.Text = "Total duration: " + totalMinutes.ToString();
      }
  </code></pre>