Dude, you can try helper functions(in codebehind). You can create another function for All gridview total & call that in codebehind after loading all the gridviews. Try this
How to Display Sum Total in the Footer of the GridView Control[
^]
EDIT
--------------------------------------
You can do this way
public partial class _Default : System.Web.UI.Page
{
decimal grdTotal1 = 0;
decimal grdTotal1 = 0;
protected void Page_Load(object sender, EventArgs e)
{
lblAllGridViewTotal.Text = (grdTotal1 + grdTotal2).ToString();
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
decimal rowTotal = Convert.ToDecimal
(DataBinder.Eval(e.Row.DataItem, "Amount"));
grdTotal1 = grdTotal1 + rowTotal;
}
if (e.Row.RowType == DataControlRowType.Footer)
{
Label lbl = (Label)e.Row.FindControl("lblTotal");
lbl.Text = grdTotal1.ToString("c");
}
}
protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
decimal rowTotal = Convert.ToDecimal
(DataBinder.Eval(e.Row.DataItem, "Amount"));
grdTotal2 = grdTotal2 + rowTotal;
}
if (e.Row.RowType == DataControlRowType.Footer)
{
Label lbl = (Label)e.Row.FindControl("lblTotal");
lbl.Text = grdTotal2.ToString("c");
}
}
}
Running Total In Gridview Footer in ASP.NET C# VB.NET[
^]
BTW you just need to change the code little bit(You can store the every summary values in state like session, viewstate, etc., then you can sum all values & you can get the result.). Let me know please.