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...
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...