472,799 Members | 1,376 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

getting the value of a selected/unselected item in a checkboxlist

I am having a bit of a problem getting the current value of the checkbox
list.

I have tried using the selected value as I thought that would give me the
current value of the check box but it appears to be giving me the first
value that is selected all the time.

I have also tried to use the selectedItem property but that does the same as
I would expect becuase the property says it get the item with the lowest
value.

How can I get the current value of a checkboxlist?

TIA,
Brett
Jun 6 '07 #1
4 4329
On Wed, 06 Jun 2007 09:33:56 -0700, Brett Wesoloski <br*********@pai.com>
wrote:
I am having a bit of a problem getting the current value of the checkbox
list.
Can you define "current value"? If multiple items in the list can be
selected (checked, in this case), what is the "current value", given that
there are multiple items with values that have been selected?
I have tried using the selected value as I thought that would give me the
current value of the check box but it appears to be giving me the first
value that is selected all the time.
Yup. The term "current value" isn't defined yet, but I am not surprised
that you get the first selected item in the list when you get the
SelectedValue.
I have also tried to use the selectedItem property but that does the
same as
I would expect becuase the property says it get the item with the lowest
value.
Actually, it says "lowest index". Note that SelectedValue and
SelectedIndex work together. In particular, all that SelectedValue does
is return the Value property of the ListItem that is at SelectedIndex.
How can I get the current value of a checkboxlist?
It's not possible to answer that question until you explain what you mean
by "current value".

Pete
Jun 6 '07 #2
What I mean by current value is the check box you just checked.

For instance I have these check boxes.

a
b
c
d
e
f
g
Now I select the b check box. The current value is b. Then I go and select
the f check box. The current value is f as that was the next check box to
be selected.

Does that help?

TIA,
Brett

"Peter Duniho" <Np*********@nnowslpianmk.comwrote in message
news:op***************@petes-computer.local...
On Wed, 06 Jun 2007 09:33:56 -0700, Brett Wesoloski <br*********@pai.com>
wrote:
>I am having a bit of a problem getting the current value of the checkbox
list.

Can you define "current value"? If multiple items in the list can be
selected (checked, in this case), what is the "current value", given that
there are multiple items with values that have been selected?
>I have tried using the selected value as I thought that would give me the
current value of the check box but it appears to be giving me the first
value that is selected all the time.

Yup. The term "current value" isn't defined yet, but I am not surprised
that you get the first selected item in the list when you get the
SelectedValue.
>I have also tried to use the selectedItem property but that does the
same as
I would expect becuase the property says it get the item with the lowest
value.

Actually, it says "lowest index". Note that SelectedValue and
SelectedIndex work together. In particular, all that SelectedValue does
is return the Value property of the ListItem that is at SelectedIndex.
>How can I get the current value of a checkboxlist?

It's not possible to answer that question until you explain what you mean
by "current value".

Pete

Jun 6 '07 #3
On Wed, 06 Jun 2007 12:08:43 -0700, Brett Wesoloski <br*********@pai.com>
wrote:
What I mean by current value is the check box you just checked.
Okay. I'll suggest that's not a broadly used concept of "current value".
:)
[...]
Now I select the b check box. The current value is b. Then I go and
select
the f check box. The current value is f as that was the next check box
to
be selected.

Does that help?
Sure. What you actually want is the checkbox that actually has *focus*.
That's entirely different from the one(s) that is(are) selected.

Not having done the ASP/web .NET stuff, I'm not sure how you can actually
get that. My first thought would be that you could enumerate the ListItem
instances in the CheckboxList and check to see which one (if any) has the
focus. But I don't see any immediate way to do that in the ListItem class.

If it's possible, it probably has something to do with the larger browser
container somehow, since in the context of a web page, focus can actually
leave the web page, and so I would not expect it to necessarily be tracked
by the web page itself. But I admit, never had to do any of the web UI
stuff, so I don't know for sure one way or the other.

As a last resort, it may be that you can track when any of the items in
the CheckboxList change, and by doing so, keep track of the one that most
recently changed. Then consider that the one with "focus" any time you
care about that.

Hopefully knowing that you are actually asking about "focus" rather than
"selection", that may help you in your search through the documentation.

Pete
Jun 7 '07 #4
Brett, did you find a solution? I'm also attempting the same thing. I have a CheckBoxList and I want to know which box was selected/unselected on SelectedIndexChanged. I'm considering rewriting the checkboxes to use a Repeater and have individual checkboxes rather than a CheckBoxList. If I did that, I'd know exactly which one had changed. Thoughts? Thanks! -Eric

EggHeadCafe.com - .NET Developer Portal of Choice
http://www.eggheadcafe.com
Jun 13 '07 #5

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

Similar topics

8
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
2
by: Jozef Jarosciak | last post by:
Hey guys, I have a listview with 7 collumns and I need to retrieve value from the first line and its 7th collumn. Is there an easy way to retrieve it? Thanks, Joe
0
by: Francois Verbeeck | last post by:
Dear UseNet readers, Does anyone have any idea on how to colorize selected checkbox in checkboxlist control ? I've quite a huge checkboxlist (approximatively one full screen) and, to improve...
1
by: rbscheer | last post by:
Hi. Is there any way to count how many items are selected on a CheckBoxList control without iterating throug the items? I have a For...Next loop that only needs to be taken into action if the...
5
by: velu | last post by:
Problem in getting value from textbox & radiobuttonlist to a valuable inside a datagid. I want to insert a record into a table thru datagrid. Here is the code (see below) Private Sub...
2
by: billyb | last post by:
My listview has two columns: Email Address & Email Address Type. I've figured out how to populate it, but now I'm having trouble figuring out how to properly use the SelectedItems to get at the...
2
by: baret bonden | last post by:
Trying to return a selected listbox item to another form .tried lots of ways; defining public variables and passing those as well as textboxes ..I' m able to display the chosen item on it's form...
4
by: planetthoughtful | last post by:
Hi All, I have a relatively simple web user control I've included in a page that simply presents 3 drop down lists and a submit button, that I use as a date picker (ie one list for day, one for...
1
by: cluce | last post by:
I have some prices listed in a checkboxlist that I am trying to add up. First I was going to add the mto a list box and add them up that way but I forgot how to do it. Its been awhile and I dont have...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?

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.