Yet another listbox question!

Z

zdrakec

Hello all:

I have two listboxes on a webform, the user selects items from the
first (which is, naturally, multi-select), and clicks a button that
will copy the selected items into the second box. The code to achieve
this is simple: I iterate through the first listbox' items collection,
and if listbox.item(x).selected is true -

if listbox1.item(x).selected then
listbox2.items.add(listbox1.item(x).text)
end if

Very straightforward. My problem is that some of my selections are
getting lost. For example, if I select the first, say, eight items in
listbox1, when the click event fires (actually, when the page load is
called again), only the first four or five items in the list will still
have selected = true, which I discovered by putting a "stop" command at
the top of page_load and walking through the list in the immediate
window.

Can someone explicate this for me? I am most definitely only populating
(or otherwise touching) listbox1 only if page.ispostback = false.

Thanks much,

zdrakec
 
Z

zdrakec

No, I actually populate the first list in the page_load event if
page.ispostback is false. I am populating the second list in the
handler of a button click event, based on the selection in the first
list. I put a Stop command at the top of the page_load event handler,
so that I could examine the selection in the first list box when the
page reloads; inevitably, even though I may have selected 9 or 10 items
from the listbox in question, only the first five (indices 0 to 4) will
show as being selected when I check...

Thanks,

zdrakec
 
Z

zdrakec

Actually, sometimes, when using the Shift key to select, say, the first
nine elements, a step-through will reveal that elements 0,1,2 are
selected, elements 3,4 are not, then elements 5,6,7 are selected, and
element 8 not.

Is the WebForms listbox defective? Has anyone else observed this
behavior?

Thanks,
zdrakec
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top