title: How to fire event handler only for the specific control in foreach loop
body: <p>Hello there I have setup some checkboxes inside a foreach loop and adding them to the page controls! I have also assigned them a single eventhandler and passing them my own parameter. </p>
  
  <p>When the checkedchanged event of checkboxes fires it calls that event handler for all the checkboxes I added This is may be because im assigning the eventhandler inside for each loop so whenever the event fires It fires for all of the check boxes! I want it to only been fired once i.e only for the checkbox whose check was changed.</p>
  
  <p>Please help me on it How can I solve the issue
  The code snippets may help you understanding the </p>
  
  <pre><code>CheckBox checkboxtemp;
  
  foreach (SPListItem item in list.Items)
          {
              checkboxtemp = new CheckBox();
              checkboxtemp.ID = "CheckBoxId" + item.ID;
              checkboxtemp.Text = item.Title;
              checkboxtemp.AutoPostBack = true;
              checkboxtemp.CheckedChanged += new EventHandler((sender, e) =&gt; checkboxtemp_CheckedChanged(sender, e, checkboxtemp.Text));
              Controls.Add(checkboxtemp);
          }
  </code></pre>
  
  <p>and the event handler which gets fired for every checkbox is as</p>
  
  <pre><code>protected void checkboxtemp_CheckedChanged(object sender, EventArgs e, string fieldName)
      {
        Label1.Text = fieldName;
      }
  </code></pre>
  
  <p>No matter which checkbox was checked. I always get the last checkbox text value inside fieldName parameter in checkboxtemp_CheckChanged event handler. i.e when ever any checkbox state gets changed the event handler in the foreach loop gets called for each items..
  I know im doing something wrong but cant figure it out </p>
  
  <p>Please help</p>