title: Multiple Footer in gridview ASP.NET C#
body: <p><br><br></p>
  
  <p>I am trying to show one table to gridview in asp.net c#. Using SQL Data Source.
  On the footer, success to show the total of each column. What I want to do is, I want to add another footer, let say.. the average of each column.</p>
  
  <p>How can i do this? Advice please.
  Thank you.</p>
  
  <p>Below are my current code:</p>
  
  <p>ASPX Page:   </p>
  
  <pre><code>&lt;asp:GridView runat="server" ID="gvGrid" AutoGenerateColumns="False" GridLines="None" PageSize="27" ShowFooter="true" DataKeyNames="ID" DataSourceID="myDataSource"&gt;
  &lt;Columns&gt;
  &lt;asp:BoundField DataField="Time" HeaderText="Time" SortExpression="OperationTime" HeaderStyle-ForeColor="Green" /&gt;     
  &lt;asp:BoundField DataField="Number1" HeaderText="Number1" SortExpression="Number1" /&gt;
  &lt;asp:BoundField DataField="Number2" HeaderText="Number2" SortExpression="Number2" /&gt;
  &lt;asp:BoundField DataField="Number3" HeaderText="Number3" SortExpression="Number3" /&gt;
  &lt;asp:BoundField DataField="Number4" HeaderText="Number4" SortExpression="Number4" /&gt;
  &lt;asp:BoundField DataField="Number5" HeaderText="Number5" SortExpression="Number5" /&gt;
  &lt;/Columns&gt;
  
  &lt;FooterStyle Font-Bold="true" /&gt;
  &lt;/asp:GridView&gt;
  
  &lt;asp:SqlDataSource ID="myDataSource" runat="server" ConnectionString="&lt;%$ ConnectionStrings:myConn %&gt;" SelectCommand="_spShowList" SelectCommandType="StoredProcedure"&gt;
  &lt;SelectParameters&gt;
  &lt;asp:ControlParameter ControlID="txtDate" Name="Date" PropertyName="Text" Type="DateTime" /&gt;
  &lt;/SelectParameters&gt;
  &lt;/asp:SqlDataSource&gt;
  </code></pre>
  
  <p>Code behind: <br><br></p>
  
  <pre><code>protected void LoadSummary()
              {
                  SqlConnection conConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["myConn"].ConnectionString);
  
                  SqlCommand cmdLoadUnit = new SqlCommand();
                  cmdLoadUnit.CommandType = CommandType.StoredProcedure;
                  cmdLoadUnit.CommandText = "_spSUMReport";
  
                  cmdLoadUnit.Parameters.AddWithValue("@Date", txtDate.Text);
                  cmdLoadUnit.Connection = conConnection;
  
                  try
                  {
                      conConnection.Open();
  
                      using (SqlDataReader myReader = cmdLoadUnit.ExecuteReader())
                      {
                          while (myReader.Read())
                          {
                              gvGrid.Columns[0].FooterText = "Total";
                              gvGrid.Columns[1].FooterText = String.Format(CultureInfo.InvariantCulture, "{0:0,0.0}", myReader["Number1"]);
                              gvGrid.Columns[2].FooterText = String.Format(CultureInfo.InvariantCulture, "{0:0,0.0}", myReader["Number2"]);
                              gvGrid.Columns[3].FooterText = String.Format(CultureInfo.InvariantCulture, "{0:0,0.0}", myReader["Number3"]);
                              gvGrid.Columns[4].FooterText = String.Format(CultureInfo.InvariantCulture, "{0:0,0.0}", myReader["Number4"]);
                              gvGrid.Columns[5].FooterText = String.Format(CultureInfo.InvariantCulture, "{0:0,0.0}", myReader["Number5"]);
                          }
                      }
                  }
                  finally
                  {
                      conConnection.Close();
                  }
              }
  </code></pre>
  
  <p>then I put LoadSummary() on page_Load event.</p>