I am trying to do an example where you programatically add items to a
CheckBoxList by modifying the Init event of the control.
I tried the following code:
private void CheckBoxList1_Init(object sender, System.EventArgs e)
{
string[] genre = {
"SciFi","Religious","Action","Comedy","Drama","Thr iller" };
int i;
for (i = 0; i < genre.GetLength(0); i++)
{
CheckBoxList1.Items.Add(new ListItem(genre[i]));
}
}
I have the following wired:
private void InitializeComponent()
{
this.CheckBoxList1.Init += new System.EventHandler(this.CheckBoxList1_Init);
this.Load += new System.EventHandler(this.Page_Load);
}
Yet, when I do a debug breakpoint on the event method, it seems to never
fire, and the control isn't updated. It works fine from Page_Load though.