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 4 978
Are you doing it in OnItemdataBound?
Patrick
"zdrakec" <zd*****@yahoo.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com... 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
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
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
So...anyone have any ideas on this one?
Thanks much,
zdrakec This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: f_salazar |
last post by:
English Version !!
Hi !!
I have a page with a Form, inside the form I have listbox with 'X' elements.
Wend I submit the page, an ASP process inside the page have to read those
elements and...
|
by: Stimp |
last post by:
I have a listbox of values that I populate from a database.
I want the user to be able to re-order the list
(by first selecting an item and then clicking 'up' or 'down' buttons)
and then save...
|
by: Steve Schroeder |
last post by:
For some reason I cannot get the OnSelectedIndexChanged event to fire for a
listbox I have on a page. I'm able to populate the listbox with data from a
stored procedure, but cannot trigger the...
|
by: Bilal Abbasi |
last post by:
I realize that you can add items to a list box as objects so you can have
access to more than just one property like the itemindex in vb6. Question I
have is how do I cause the listbox to show a...
|
by: George |
last post by:
Sub ExcelToListBox()
Dim xRange As Object
Dim ary
Dim xValue As String
xRange = oXL.Range("A1:A9") 'has letters A-H
ary = xRange.value
xValue = ary(3, 1) 'xValue = C...
|
by: |
last post by:
Greets All,
Question on data in datagrid /listbox and looping?
I’m trying to decide the best way to write this code.
1 would like the user to make several selections from one listbox/combo box...
|
by: |
last post by:
Greets All,
Question on data in datagrid /listbox and looping?
I’m trying to decide the best way to write this code.
1 would like the user to make several selections from one listbox/combo box...
|
by: dan NY |
last post by:
I'm a struggling new VB Applications user that has what may be a simple question, but I've been struggling with it.
I'm using a response to a message box YesNo question to cause one of two...
|
by: caracolito1975 |
last post by:
Hi to every one!!!!
For some time now I'm programing in .NET and I have a question in
using ListBox
I need to databind a collection to a ListBox. My code is something
like this:
using...
|
by: jh |
last post by:
I'd like to copy/paste into a listbox during runtime. I can do this for a
textbox but can't figure out how to accomplish this for a listbox. Any
help? Thanks.
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |