Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

C# Programming

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

On Wed, 06 Jun 2007 09:33:56 -0700, Brett Wesoloski <brwesolo@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

-----------------------------------------------Reply-----------------------------------------------

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" <NpOeStPe@nnowslpianmk.com> wrote in message

news:op.ttigplpr8jd0ej@petes-computer.local...

On Wed, 06 Jun 2007 12:08:43 -0700, Brett Wesoloski <brwesolo@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

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc