Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: ASP
Posted by: Mario Lopes
Added: Aug 23, 2018 5:55 PM
Views: 18
Tags: gridview total
Este código calcula o total de uma gridview e mostra no footer
  1.  
  2. 1. definir a variável global
  3. public partial class soma : System.Web.UI.Page
  4. {
  5.     int total=0;
  6. 2. eis o código
  7.  
  8. protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
  9.    {
  10.        if (e.Row.RowType == DataControlRowType.DataRow)        
  11.        {
  12.            total=total+ Convert.ToInt32(e.Row.Cells[2].Text);        
  13.        }
  14.        if (e.Row.RowType == DataControlRowType.Footer){
  15.            e.Row.Cells[0].Text = total.ToString();
  16.        }
  17.    }