473,480 Members | 2,840 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

checkboxlist - determine checkbox that caused control to fire

Hi all,

I have a CheckBoxList control which has about 10 items. I have set
autopostback=true and also set an eventhandler for OnSelectedIndexChanged.
The problem is I want to identify which checkbox item caused the event to
fire to perform some routines based upon the value of that individual
checkbox. How can I determine this? For example, 5 of the 10 items maybe
checked. However, when I uncheck one, I want to perform some code based upon
the value of just that 1 checkbox that fired the event.

TIA!
Jul 28 '07 #1
3 3473
On Jul 28, 7:09 am, <pa...@community.nospamwrote:
Hi all,

I have a CheckBoxList control which has about 10 items. I have set
autopostback=true and also set an eventhandler for OnSelectedIndexChanged.
The problem is I want to identify which checkbox item caused the event to
fire to perform some routines based upon the value of that individual
checkbox. How can I determine this? For example, 5 of the 10 items maybe
checked. However, when I uncheck one, I want to perform some code based upon
the value of just that 1 checkbox that fired the event.

TIA!
HI...

in the OnSelectedIndexChanged eventhandler you access selectedItem..
and more hover you can loop through the items on the items of the
checkboxlist... you can check the value... or to some extent you can
also add custom attribute to your item... then check the value and
perhaps attribute to do your job....
could you give a example exactly what are you trying to accomplish...

Thanks
Md. Masudur Rahman (Munna)
Kaz Software Ltd.
www.kaz.com.bd
http://munnacs.110mb.com

Jul 28 '07 #2
pa***@community.nospam wrote:
Hi all,

I have a CheckBoxList control which has about 10 items. I have set
autopostback=true and also set an eventhandler for
OnSelectedIndexChanged. The problem is I want to identify which
checkbox item caused the event to fire to perform some routines based
upon the value of that individual checkbox. How can I determine this?
For example, 5 of the 10 items maybe checked. However, when I uncheck
one, I want to perform some code based upon the value of just that 1
checkbox that fired the event.
You can't identify which checkbox caused the event to fire, because several
may be selected, and the control doesn't keep track of which one was changed
(it does keep track internally, but it doesn't let you know).

You'll have to store the list of selected items before the postback in
ViewState, and compare this with the selected items after postback.

Another option might be to replace the checkboxlist with a set of separate
checkboxes, and link them all to the same OnCheckedChanged handler. The
first parameter of the event handler (sender) will refer to the checkbox
that caused the postback.

--

Riki
Jul 28 '07 #3
Maybe MS should consider opening up that hidden property to let me know
which checkbox fired the event in the CheckBoxList.

Anyways, I like your second idea. Maybe, I will give that a shot.

thanks

"Riki" <ri**@dontnagme.comwrote in message
news:e7**************@TK2MSFTNGP03.phx.gbl...
pa***@community.nospam wrote:
>Hi all,

I have a CheckBoxList control which has about 10 items. I have set
autopostback=true and also set an eventhandler for
OnSelectedIndexChanged. The problem is I want to identify which
checkbox item caused the event to fire to perform some routines based
upon the value of that individual checkbox. How can I determine this?
For example, 5 of the 10 items maybe checked. However, when I uncheck
one, I want to perform some code based upon the value of just that 1
checkbox that fired the event.

You can't identify which checkbox caused the event to fire, because
several may be selected, and the control doesn't keep track of which one
was changed (it does keep track internally, but it doesn't let you know).

You'll have to store the list of selected items before the postback in
ViewState, and compare this with the selected items after postback.

Another option might be to replace the checkboxlist with a set of separate
checkboxes, and link them all to the same OnCheckedChanged handler. The
first parameter of the event handler (sender) will refer to the checkbox
that caused the postback.

--

Riki

Jul 28 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
5519
by: Egbert | last post by:
I use a System.Web.UI.WebControls.CheckBoxList object to fill a list. I need to label groups of checkboxes in the list by Category (Determined dynamically from the database) at runtime. Is it...
0
7928
by: Bryce Budd | last post by:
Hello All, I've been a taker of information from newsgroups for a long time and thought I'd finally make a contribution back to the community whose supported me when I've needed it. After all...
3
5438
by: Robin Day | last post by:
I run some code on the changed event of checkbox lists. Its quite simple, nothing more than showing / hiding some other parts of the page. Using Autopostback and Server side code works fine, but is...
4
8056
by: dm_dal | last post by:
Is there a know issue surrounding the CheckBoxList control and it's viewstate? When my control is created, it's ListItems are checked as needed, but on a postback, they loose their Selected...
3
6669
by: JD | last post by:
Hello, I have a problem with checkboxlist inside Repeater (in ASP.NET page). I am able to create Checkboxlist and bind it (inside Repeater_ItemBound - including setting checked/unchecked)....
5
13372
by: Patrick.O.Ige | last post by:
I'm binding a CheckBoxlist below in the ItemDataBound(the CheckBoxList is in a Datalist) By doing "li.Selected = True" i can see all the checkBoxes are selected. But what i want is to be able...
4
4024
by: Patrick.O.Ige | last post by:
I have a CheckBoxList in a DataList and i'm trying to get item Selected after doing a postBack. I have set my CheckBoxlist AutoPostBack="True" Any ideas what 'm doing wrong? It seems not to...
0
2130
by: webmaster | last post by:
Hi all, I'm tearing my hair out with this one. I have successfully implemented by own RadioButtonList in order to provide additional functionality and a DIV rather than TABLE-based layout in...
0
7060
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6760
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5365
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4799
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4501
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3013
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3004
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1311
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
572
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.