How to attach programmatically created CheckBoxList controls to their event handlers
I have an **ASP.NET Web Forms** application.

In my application I create several `CheckBoxList`controls programmatically. I do not know in advance how many `CheckBoxList` are created at runtime but I know their IDs. 

Now everytime a `CheckBox` of a specific `CheckBoxList` is checked the `ItemCheck` event is raised and I can use a event handler to perform some operations (mainly queries). Of course the operation to perform does not depend just on the `CheckBox` but also on the `CheckBoxList` selected.

Now I have the following options:

 1. When I create a `CheckBoxList` I can also programmatically create its **event handler** (I guess it is possible)

 2. Create a single event handler for all the `CheckBoxList` controls and use `Object sender` and `ItemCheckEventArgs e` to understand which `CheckBoxList` and `CheckBox` were checked (how do I link all these controls to a single event handler)?

Is my reasoning correct? Is there any other better option to perform this task? If it is not the case, which one is the right approach to choose? Thanks


How to attach programmatically created CheckBoxList controls to their event handlers
===

I have an **ASP.NET Web Forms** application.

In my application I create several `CheckBoxList`controls programmatically. I do not know in advance how many `CheckBoxList` are created at runtime but I know their IDs. 

Now everytime a `CheckBox` of a specific `CheckBoxList` is checked the `ItemCheck` event is raised and I can use a event handler to perform some operations (mainly queries). Of course the operation to perform does not depend just on the `CheckBox` but also on the `CheckBoxList` selected.

Now I have the following options:

 1. When I create a `CheckBoxList` I can also programmatically create its **event handler** (I guess it is possible)

 2. Create a single event handler for all the `CheckBoxList` controls and use `Object sender` and `ItemCheckEventArgs e` to understand which `CheckBoxList` and `CheckBox` were checked (how do I link all these controls to a single event handler)?

Is my reasoning correct? Is there any other better option to perform this task? If it is not the case, which one is the right approach to choose? Thanks

