Gaurav Kumar

Gaurav Kumar

  • NA
  • 706
  • 203.2k

Show total in Gridview's footer, w/o template or bounded

Jul 20 2015 2:20 AM

Hi All,

I want to show total in gridview's footer. If I had template field or bounded field in my gridview I could have done it before but in my scenario it's different.

I need to show total for all columns except the first column because it doesn't have integer it's a string.

Below is my gridview.

<asp:GridView ID="GVReport" runat="server" Width="1200px" CellPadding="4" EnableModelValidation="True" AllowPaging="True" onpageindexchanging="GVEmployee_PageIndexChanging" ForeColor="#333333" GridLines="None" ondatabound="GVReport_DataBound" onrowdatabound="GVReport_RowDataBound" ShowFooter="True"> 
<AlternatingRowStyle BackColor="White" /> 
<FooterStyle BackColor="#507CD1" ForeColor="White" Font-Bold="True" /> 
<HeaderStyle BackColor="#006666" ForeColor="White" Font-Bold="True" /> 
<PagerStyle BackColor="#006666" ForeColor="White" HorizontalAlign="Center" /> 
<RowStyle BackColor="#ffcc00" /> <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" /> 
</asp:GridView>

and here I am binding the gridview

protected void Bind_Grid()
{
DateTime Date; DateTime.TryParseExact(lblDate.Text, "dd/MM/yyyy", new CultureInfo("en-US"), DateTimeStyles.None, out Date); 
Business_Logic bal = new Business_Logic();
DataTable dt = new DataTable();
dt = bal.TMS_Report(Date.Date, lblEmpCode.Text);
if (dt.Rows.Count > 0)
{
GVReport.DataSource = dt;
GVReport.DataBind();
GVReport.Visible = true;
}
}

Gridview is binding perfectly. Hpw can I show the total in footer?

see my bounded gridview in below image


Answers (15)