title: Why is Gridview footer adding an extra column?
body: <p>Can't believe I have to ask this - you'd think such a basic feature would be straightforward to implement, but I'm having trouble creating a footer for a Gridview. I've checked out various tutorials and other questions, such as <a href="http://highoncoding.com/Articles/98_Adding_a_New_Row_in_GridView.aspx" rel="nofollow noreferrer">here</a>, and <a href="http://msdn.microsoft.com/en-us/library/bb310552.aspx" rel="nofollow noreferrer">here</a> and <a href="https://stackoverflow.com/questions/12545919/how-do-i-add-footertemplate-to-gridview-with-bountfields">here</a>, but am still encountering difficulties.</p>
  
  <p>The problem is in displaying the footer properly (i.e. without adding an extra empty column). From what I gather, you need to put the FooterTemplate inside a TemplateField tag or it won't work - at least it wouldn't compile for me. If I insert this after the BoundFields columns then it adds an extra column which is not desirable. </p>
  
  <pre><code>&lt;asp:GridView ID="gridview1" runat="server" AutoGenerateColumns="false" AllowSorting="true"
      CellPadding="3" HorizontalAlign="Center" GridLines="both" CssClass="dataTable1"
      OnRowDataBound="Colour_Columns" Caption="PARTIAL COMPARE" ShowFooter="true"&gt;
      &lt;HeaderStyle BackColor="Black" ForeColor="AntiqueWhite" Height="30" CssClass="header" /&gt;
      &lt;FooterStyle BackColor="Black" ForeColor="AntiqueWhite" Height="30" CssClass="footer" /&gt;
      &lt;Columns&gt;
          &lt;asp:BoundField DataField="FOLDER" HeaderText="Location" /&gt;
          &lt;asp:BoundField DataField="FILE" HeaderText="File" /&gt;
          &lt;asp:BoundField DataField="CHECKSUM" HeaderText="Checksum" Visible="false" /&gt;
          &lt;asp:BoundField DataField="STATUS" HeaderText="Status" /&gt;
          &lt;asp:BoundField DataField="DATE" HeaderText="Date" Visible="false" /&gt;
          &lt;asp:TemplateField&gt;
              &lt;FooterTemplate&gt;
                  &lt;asp:Button ID="UpdateButton" runat="server" Text="UPDATE" CssClass="updateButton" /&gt;
              &lt;/FooterTemplate&gt;
          &lt;/asp:TemplateField&gt;
       &lt;/Columns&gt;
  &lt;/asp:GridView&gt;
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/gzQKa.jpg" alt="enter image description here"></p>
  
  <p>Similarly, if I put it before the BoundFields it adds an extra column on the left. If I try to put all the BoundFields under the TemplateField it won't compile.</p>
  
  <p>How do I add the footer to the gridview without creating an extra column? Also, while we're at it, how can I set its colspan to 1? (It's only going to have the one Update button in it, so no need for three columns in the footer.)</p>
  
  <p><strong>Colour-Scheme method:</strong></p>
  
  <pre><code>protected void Colour_Columns(Object sender, GridViewRowEventArgs e)
  {
      if (e.Row.RowType == DataControlRowType.DataRow)
      {
          if (e.Row.Cells[3].Text == "Match")
             e.Row.BackColor = Color.Lime;
          if (e.Row.Cells[3].Text == "Mismatch")
             e.Row.BackColor = Color.Gold;
          if (e.Row.Cells[3].Text == "New File")
             e.Row.BackColor = Color.PeachPuff;
      }
  }
  </code></pre>
  
  <p>This method does not seem to recognize ItemTemplate values...</p>