Programmatic CheckBox Event Not Firing

  • Thread starter Thread starter DotNetJunkies User
  • Start date Start date
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
 
Thank you chaps, been puzzled by such a simple property that I hav completely
forgotten.

Andrew
 
Back
Top