
10/05/2008, 12:56
|
 | Colaborador | | Fecha de Ingreso: septiembre-2007 Ubicación: San Francisco, United States
Mensajes: 3.858
Antigüedad: 17 años, 6 meses Puntos: 87 | |
Re: suma de columna en un datagrid en una webform implementa este evento en tu dgv
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
int valueQty=0;
if(int.TryParse(e.Row.Cells[3].Text,out valueQty)) // en mic aso la 4ta columna es la q me interesa
total += valueQty;
}
if (e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[0].Text = string.Empty;
e.Row.Cells[1].Text = string.Empty;
e.Row.Cells[2].Text = "Total:";
e.Row.Cells[3].Text = total.ToString();
total = 0;
}
} |