You must Sign In to post a response.
  • Category: .NET

    How to display Subtotals and totals in Asp.net Gridview

    Hi frns

    Pls let me know how to display Subtotals and totals In a Asp.net gridview..

    For example consider..i have 3 coloums in gridivew...Account Number,Account and Income...

    Based on Account i need to group the records and display the subtotoal for each Accout...and finnaly the Total.

    Pls help me friends

    Madhu
  • #153295
    hai

    you use this code in grid databound evend


    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)

    {

    if (e.Row.RowType == DataControlRowType.DataRow)

    {

    GridView gv = e.Row.FindControl("gvReports") as GridView;



    GridViewRow footerRow = gv.FooterRow;



    foreach (GridViewRow row in gv.Rows)

    {

    Label labelTotal = footerRow.FindControl("lblTotal") as Label;



    dayHour += Double.Parse((row.FindControl("lblHour") as Label).Text);

    labelTotal.Text = dayHour.ToString();

    }



    totalHour += dayHour;



    dayHour = 0.0;

    }

    }


    ok

    by
    suthahar.j
    pullanviduthi
    pudukkottai
    jstech.4t@gmail.com

    J.Suthahar
    www.jssuthahar.com
    Be Simple Be Sample


This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.