Click here to Skip to main content
16,017,608 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello sir
i want take [ALL COLUMN ] total in footer grid view please tell easy way ....
Posted

Hey ...

Create grid view like this

XML
<asp:GridView ID="gv" runat="server" ShowFooter="true">
                    </asp:GridView>


and write the c# code like..
C#
protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        gv.RowDataBound += new GridViewRowEventHandler(gv_RowDataBound);
    }
    double sum = 0;
    protected void gv_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            sum += Convert.ToDouble(e.Row.Cells[0].Text);
        }
        if (e.Row.RowType == DataControlRowType.Footer)
        {
            e.Row.Cells[0].Text = sum + "";
        }
    }

i think may help to solve ur prob...
 
Share this answer
 
Comments
Amit chirutkar 27-Sep-10 7:49am    
Thank u so much sir
Amit chirutkar 27-Sep-10 7:49am    
Reason for my vote of 5
Automatic vote of 5 for accepting answer.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900