order of events - dynamic checkbox events

G

Guest

Hi there,

I am databinding a datagrid on the onload with the usual !IsPostBack
condition.

I have to create some dynamic checkboxes, because i dont know how many i
will need until the dataset comes back. take it as red that writing them into
the aspx is not an option.

So on the databind function of my grid I am doing the following:

CheckBox cb = new CheckBox();
cb.AutoPostBack=true;
cb.CheckedChanged += new System.EventHandler(cbPersonSelect_CheckChanged);

Once the page has loaded, hitting the checkbox just causes a postback and
nothing else. It is not raising the event. I know it is referencing the
correct function because if i change the above to
cb.CheckedChanged += new
System.EventHandler(cbPersonSelectBLAHBLAH_CheckChanged);

It says my page definition doesnt contain cbPersonSelectBLAHBLAh etc..

I know it has something to do with the Page_Init which instanstiates all
server control events or something like that but I've tried some different
ways (putting the databind in the Page_Init etc) and it never raises the
event. Does anyone have a work around or can tell me what i'm doing wrong?
All i want to do is tell the checkbox to raise an event it cant be that hard
! Thanks.


cell.Controls.Add(cb);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top