Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / July 2007

Tip: Looking for answers? Try searching our database.

checkboxlist - determine checkbox that caused control to fire

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
param@community.nospam - 28 Jul 2007 02:09 GMT
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!
Masudur - 28 Jul 2007 09:05 GMT
On Jul 28, 7:09 am, <pa...@community.nospam> wrote:
> Hi all,
>
[quoted text clipped - 7 lines]
>
> 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
Riki - 28 Jul 2007 14:30 GMT
> Hi all,
>
[quoted text clipped - 6 lines]
> 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.

Signature

Riki

param@community.nospam - 28 Jul 2007 18:32 GMT
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

>> Hi all,
>>
[quoted text clipped - 18 lines]
> first parameter of the event handler (sender) will refer to the checkbox
> that caused the postback.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.