how to write the code in chechk_checkedchanged event when the check box is dynamically created

May 19 2010 8:04 AM
hi i created one check box dynamically and added to table like bellow
CheckBox chk=new CheckBox();
chk.AutoPostBack = true;
chk.CheckedChanged += new EventHandler(chk_CheckedChanged);
tbcell3.Controls.Add(chk);
 tbrow1.Cells.Add(tbcell3);
 tbl.Controls.Add(tbrow1);
        this.Controls.Add(tbl);

like this the check box was created dynamically now i want to write the code in chk_checkedchanged event
how to write that, i tried like bellow but i didn't get result

 void chk_CheckedChanged(object sender, EventArgs e)
    {
        tbl.BackColor = Color.Black;
    }

Answers (2)