473,385 Members | 1,912 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 2011
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: AFN | last post by:
I want to click a checkbox and have a 4 line (approx) paragraph appear beneath the checkbox, pushing the rest of the page down. And when unchecking the checkbox, the paragraph should disappear...
2
by: alien2_51 | last post by:
Can some one tell me why the onclick is firing twice for the radion button and checkbox controls...? <%@ Page Language="vb" AutoEventWireup="false" Codebehind="Testing.aspx.vb"...
5
by: Greg Hurlman | last post by:
I've got a very simple ASCX page, where once someone finishes a section and clicks the "Next >" button, the section they just finished is disabled, and the next section appears below it, and so on....
3
by: Jack Turnbull | last post by:
Hi, I have a Checkbox in a Repeater set to AutoPostBack = true. I have pointed OnCheckedChanged to a Sub but it doesn't fire. If I move the checkbox out of the Repeater it fires! Any ideas? Thanks
5
by: tshad | last post by:
Is there a way to allow a user to press a radio button if it is already selected? There is an onCheckedChanged event that fires when the person presses the button and it is isn't selected...
1
by: rodchar | last post by:
hey all, is the following even possible? i have a datagrid with checkboxes on each row, when a user clicks on the checkbox i'd like to populate one of the fields in the grid with the current...
2
by: dilip.movva | last post by:
Hi, In the ItemDataBound of my datagrid I am creating a checkbox dynamically. I have the eventhandler defined for CheckedChanged of the check box. The event is not firing. The grid is bound in the...
2
by: Deano | last post by:
I have a subform that is populated by a table that holds lots of yes/no values. The user sees points at the side and then periods across the top. So they decide they want point 20 for period 5...
4
by: sarabonn | last post by:
Hello everyone, Iam firing a event in the chechbox_checkedchanged. It works fine private void checkBox1_CheckedChanged(object sender, EventArgs e) { ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.