Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Programmatic CheckBox Event Not Firing

Reply
Thread Tools

Programmatic CheckBox Event Not Firing

 
 
DotNetJunkies User
Guest
Posts: n/a
 
      10-21-2004
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.
 
Reply With Quote
 
 
 
 
Cirrosi
Guest
Posts: n/a
 
      10-21-2004
You don't have set autopostback=true;

"DotNetJunkies User" <(E-Mail Removed)> ha scritto nel
messaggio news:%23$(E-Mail Removed)...
> 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.



 
Reply With Quote
 
 
 
 
Ken Cox [Microsoft MVP]
Guest
Posts: n/a
 
      10-21-2004
Not sure, but did you trying setting Autopostback to true?

"DotNetJunkies User" <(E-Mail Removed)> wrote in message
news:%23$(E-Mail Removed)...
> 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.


 
Reply With Quote
 
=?Utf-8?B?QW5kcmV3?=
Guest
Posts: n/a
 
      10-21-2004
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.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CheckChanged event not firing when unchecking CheckBox in GridView jlficken@gmail.com ASP .Net 1 07-12-2007 03:58 PM
programmatic firing of keydown event runner7 Javascript 9 09-11-2006 12:47 AM
Dynamic CheckBox CheckedChanged event not firing dilip.movva@gmail.com ASP .Net 2 10-17-2005 04:23 PM
RadioButton (or Checkbox) event firing if selected (not changed) tshad ASP .Net 5 03-15-2005 09:36 AM
CheckBox Changed Event Not Firing in DataGrid shiv ASP .Net Web Controls 0 06-18-2004 08:33 PM



Advertisments