title: CheckBox in GridView firing CheckedChanged event at wrong time
body: <p>I have a checkbox in my gridview footer with autopostack=true (which should fire a checkedchanged event), and a linkbutton in my itemtemplate (which should fire the gridview rowcommand event).</p>
  
  <p>Everything has been working fine, until I placed the following code in my gridview rowdatabound (or databound) event:</p>
  
  <pre><code>        for (int i = 0; i &lt; gridCartRows.Columns.Count - 2; i++)
          {
              e.Row.Cells.RemoveAt(0);
          }
  
          e.Row.Cells[0].ColumnSpan = gridCartRows.Columns.Count - 1; 
  </code></pre>
  
  <p>Now, when I click my linkbutton, the checkbox checkedchanged event is automatically fired, and then the rowcommand event is fired.</p>
  
  <p>Why is the checkedchanged event being fired when it shouldn't, when I add the above code? </p>
  
  <p>Is there a way to get around this?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>Here's a sample, that reproduces my issue:</p>
  
  <pre><code>    &lt;asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" ShowFooter="True"
          OnRowCommand="GridView1_RowCommand" OnRowDataBound="GridView1_RowDataBound"&gt;
          &lt;Columns&gt;
              &lt;asp:TemplateField HeaderText="Column1"&gt;
                  &lt;ItemTemplate&gt;
                  &lt;/ItemTemplate&gt;
              &lt;/asp:TemplateField&gt;
              &lt;asp:TemplateField HeaderText="Column2"&gt;
                  &lt;ItemTemplate&gt;
                      &lt;asp:LinkButton ID="LinkButton1" runat="server" Text="Fire Row Command" CommandName="Fire" /&gt;
                  &lt;/ItemTemplate&gt;
                  &lt;FooterTemplate&gt;
                      Footer
                      &lt;asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="true" OnCheckedChanged="CheckBox1_CheckedChanged" /&gt;
                  &lt;/FooterTemplate&gt;
              &lt;/asp:TemplateField&gt;
              &lt;asp:TemplateField HeaderText="Column3"&gt;
                  &lt;ItemTemplate&gt;
                  &lt;/ItemTemplate&gt;
              &lt;/asp:TemplateField&gt;
          &lt;/Columns&gt;
      &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>Code-behind:</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
      if (!IsPostBack)
      {
          GridView1.DataSource = new int[5];
          GridView1.DataBind();
      }
  }
  
  protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
  {
      if (e.Row.RowType == DataControlRowType.Footer)
      {
          for (int i = 0; i &lt; GridView1.Columns.Count - 2; i++)
          {
              e.Row.Cells.RemoveAt(0);
          }
          e.Row.Cells[0].ColumnSpan = GridView1.Columns.Count - 1;
  
          ((CheckBox)e.Row.FindControl("CheckBox1")).Checked = true;
      }
  }
  
  protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
  {
      if (e.CommandName == "Fire")
      {
          Response.Write("RowCommand fired.");
      }
  }
  
  protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
  {
      Response.Write("CheckBox fired.");
  }
  </code></pre>
  
  <p>Note, I'm setting the CheckBox property to true in the RowDataBound - if I remove this, it works fine. So merging the cells and setting the checkbox property aren't working nicely together.</p>