|
-
Aug 28th, 2006, 02:42 PM
#1
Thread Starter
Fanatic Member
Checkbox List Item selected
When a user clicks a checkbox in my checkbox list I want to get the column numer they clicked on. For example, if they click the first box the number should be 0, the second box should be 1, and so on.
I tried this
rblAlerts.SelectedIndex
But this always return a 0 value no matter which check box is clicked. I have my code in the SelectedIndexChanged sub.
I am using VB .Net 2003.
Thanks
-
Aug 28th, 2006, 09:13 PM
#2
Re: Checkbox List Item selected
Do you have autopostback=True for the control?
-
Aug 29th, 2006, 08:28 AM
#3
Thread Starter
Fanatic Member
Re: Checkbox List Item selected
Yes the auto postback value is set to True. If it wasn't then nothing would happen when the user clicked on the check box list. Like I said before I am getting the 0 value back no matter which check box the user clicks on.
-
Aug 29th, 2006, 09:27 AM
#4
Re: Checkbox List Item selected
Do any of your items share the same value, but different display text?
-
Aug 29th, 2006, 10:33 AM
#5
Re: Checkbox List Item selected
The event that handles the checkboxlist checkbox selection should have a... say, ItemIndex. So you can go
e.Item.ItemIndex or e.ItemIndex.
-
Aug 30th, 2006, 09:00 AM
#6
Thread Starter
Fanatic Member
Re: Checkbox List Item selected
I don't think this works in the selectedindexchanged sub of either the radiobuttonlist control or the checkboxlist control. This is the only way that I could make it work.
if radiobuttonList1.items(0).selected = true then blah
if radiobuttonlist1.items(1).selected = true then blah
It would be more efficient if I could get back the slected value in one line of code than having to check for all possible radio buttons that could be selected.
-
Aug 30th, 2006, 01:16 PM
#7
Thread Starter
Fanatic Member
Re: Checkbox List Item selected
I was wrong about the radiobuttonList. You can use radiobuttonList.selectedindex and that will give you the row that is selected.
However, I don't think this is possible for the CheckBoxList since more than one of these can be checked.
-
Sep 7th, 2006, 09:56 AM
#8
New Member
Re: Checkbox List Item selected
Yes, you can get the clicked item ID by accessing
Page.Request.Form["__EVENTTARGET"]
in the event CheckboxList_SelectedIndexChanged.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|