In asp.net C#, How can I get the sum total of a column in the gridview to a textbox outside the gridview?
Note: Gridview data is not coming from any database it is being entered manually by the user.
Call this Method on some button click or on new row creation or whatever event you want to
private void GrandTotal()
{
float GTotal = 0f;
for (int i = 0; i < GridView1.Rows.Count; i++)
{
String total = (GridView1.Rows[i].FindControl("lblTotal") as Label).Text;
GTotal += Convert.ToSingle(total);
}
txtTotal.text=GTotal.toString();
}
Hope i helped :D