Dotnet bug? (asp dropdown list)

P

Paul Eason

I have identified a re-creatable issue that may be a bug
and may be by design?

I have a Webform with two dropdown lists on it, each with
a different name and different tab index but they both
have the same data. I populate them by using listitems
which are then set to nothing afterwards (see code
extract below). However, because I am adding the same
sourceitem to both controls they then seem to be treated
as one object and any attempt to edit one. edits the
other....Let me demonstrate

----------------------
(form contains unbound dropdown lists - lstUserDepartment
and lstRequesterDepartment)

dim lstItem as listItem

lstitem = new listitem
lstitem.value = 1
lstitem.text = "Brighton"
lstUserDepartment.items.add (lstItem)
lstRequesterDepartment.items.add (lstItem)
'should be harmless enough...
lstitem=nothing

lstitem = new listitem
lstitem.value = 2
lstitem.text = "Paris"
lstUserDepartment.items.add (lstItem)
lstRequesterDepartment.items.add (lstItem)
lstitem=nothing

etc....

Now later in the code when Im trying to set the values..

lstUserDepartment.items.findbyvalue(myrecordset.fields
("UserDept").value).selected=true

This line changes BOTH listboxes to the same selected
item. And the next line..

lstRequesterDepartment.items.findbyvalue
(myrecordset.fields("requesterDept").value).selected=true

....generates an error "A droplist cannot have multiple
lines selected". This is telling me that both objects are
now refering to the same physical memory space.

I know there is a workaround which is basically to create
two seperate listitem collections containing the same
data and assigning one to each control but this is a
waster of memory/resources...
 
B

bob smith

Hi,
i had the same issue using AddRange method on Items .. i do a loop and
adding one by one the different items do work well..

Thank you for reporting the bug

Alexandre puissant
 

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,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top