Programmatic CheckBox Event Not Firing

D

DotNetJunkies User

Hi,

I have a checkbox control programmatically created for each row in the datagrid but CheckedChanged event not firing when state of the checkbox changes.

I use the following code to instantiate ItemTemplate with checkbox contructor:

public class TemplateObject : ITemplate {
public void InstantiateIn(Control objContainer) {
CheckBox objCheckBox = new CheckBox();
objCheckBox.ID = "Item";
objCheckBox.CheckedChanged +=new EventHandler(objCheckBox_CheckedChanged);
objContainer.Controls.Add(objCheckBox);
}

public void objCheckBox_CheckedChanged(object sender, EventArgs e) {
CheckBox objCheckBox = (CheckBox)sender;
if(objCheckBox.Checked) {
//Do Something
}
}
}

Any advice much appreciated.


Andrew
 
G

Guest

Thank you chaps, been puzzled by such a simple property that I hav completely
forgotten.

Andrew
 

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

Staff online

Members online

Forum statistics

Threads
473,991
Messages
2,570,217
Members
46,805
Latest member
ClydeHeld1

Latest Threads

Top