title: how to add event handler to programatically created checkboxes
body: <p>This is my code for adding a check box progrmatically but it doesnt let me add an event onchecked</p>
  
  <pre><code>protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
  {
  
          CheckBox chk = new CheckBox();
          chk.EnableViewState = true;
          chk.Enabled = true;
  
          chk.ID = "chkb";
          DataRowView dr = (DataRowView)e.Row.DataItem;
  
  
          e.Row.Cells[0].Controls.Add(chk);
  
          e.Row.TableSection = TableRowSection.TableBody;
      }
  </code></pre>
  
  <p>when I try to add this:   </p>
  
  <pre><code>chk.CheckedChanged += checkBox_CheckedChanged;
  I get this error : 
  "The name 'checkBox_CheckedChanged' does not exist in the current context",
  </code></pre>
  
  <p>even though I have already added this function:</p>
  
  <pre><code>   private void CheckBox_CheckedChanged(object sender, System.EventArgs e)
    {
     Response.Write("in check changed object");
    }
  </code></pre>