472,353 Members | 983 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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 3404
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
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...
0
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...
3
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...
4
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,...
3
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...
5
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...
4
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...
0
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...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...

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.