ASP.NET 2.0 CheckboxList Question - VS 2005 RC1

  • Thread starter Thread starter ACE FAN
  • Start date Start date
A

ACE FAN

I am using a checkbox list populated from a dataset table. The list has
about 24 items. In the SelectedIndexChanged event, the SelectedIndex of
the checkbox list always returns the lowest selected index of the list
inistead of what I clicked on.

So if item 3 is checked and I check on item 10, the selected index of
the control is always 3. How can I get the index of what was selected?
The eventArgs is empty.

Can anyone help me please?

Curt
 
The CheckboxList control is designed to give a list of the checkboxes
checked, not what has changed. If you need that granular control (knowing not
only what is and is not checked, but what item was selected last), you would
be best served with one of two options:

1. Write your own control. You can inherit from the CheckBoxList to save
some time, although you will have to completely rewrite some of the more
"time consuming" methods (meaning time to author and not performance of the
control).

2. Use individual checkboxes. If you go this route, wrap it in either a User
control or a composite control for better reuse.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 
Back
Top