This first section is in a loop. It creates the dynamic check boxes with no problems.
// All I am doing here is incrementing our session counter
int id = Convert.ToInt32(Session["id"]);
id++;
Session["id"] = id;
// Now I create my checkbox
chkDynamic = new CheckBox();
chkDynamic.Text = "hey";
string chk = "chk" + id.ToString();
chkDynamic.ID = chk;
chkDynamic.CheckedChanged += new EventHandler(this.chkDynamic_CheckedChanged);
Panel1.Controls.Add(chkDynamic);
My event handler is not wiring up for this. Strangly if I hard code the ID it does work, but only for one iteration of the loop because if we hard coded the IDs then we would run into 'multiple id errors'
protected void chkDynamic_CheckedChanged(object sender, EventArgs e)
{
if (chkDynamic.Checked)
Response.Write( "you checked the checkbox");
else if (!chkDynamic.Checked)
Response.Write("checkbox is not checked");
}