469,631 Members | 1,743 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,631 developers. It's quick & easy.

Programmatic CheckBox Event Not Firing

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

---
Posted using Wimdows.net NntpNews Component -

Post Made from http://www.DotNetJunkies.com/newsgroups Our newsgroup engine supports Post Alerts, Ratings, and Searching.
Nov 18 '05 #1
3 1911
You don't have set autopostback=true;

"DotNetJunkies User" <User@-NOSPAM-DotNetJunkies.com> ha scritto nel
messaggio news:%2****************@TK2MSFTNGP09.phx.gbl...
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

---
Posted using Wimdows.net NntpNews Component -

Post Made from http://www.DotNetJunkies.com/newsgroups Our newsgroup
engine supports Post Alerts, Ratings, and Searching.

Nov 18 '05 #2
Not sure, but did you trying setting Autopostback to true?

"DotNetJunkies User" <User@-NOSPAM-DotNetJunkies.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
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

---
Posted using Wimdows.net NntpNews Component -

Post Made from http://www.DotNetJunkies.com/newsgroups Our newsgroup
engine supports Post Alerts, Ratings, and Searching.


Nov 18 '05 #3
Thank you chaps, been puzzled by such a simple property that I hav completely
forgotten.

Andrew

"DotNetJunkies User" wrote:
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

---
Posted using Wimdows.net NntpNews Component -

Post Made from http://www.DotNetJunkies.com/newsgroups Our newsgroup engine supports Post Alerts, Ratings, and Searching.

Nov 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Greg Hurlman | last post: by
3 posts views Thread by Jack Turnbull | last post: by
1 post views Thread by rodchar | last post: by
2 posts views Thread by dilip.movva | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.