I'm having a weird problem in ASP.NET 1.1. I have two DropDownLists in
a form. Both lists are build identically but separately. Somehow the
DropDownLists are getting crossed in memory, because when I set the
SelectedValue for the second list, the first list's SelectedValue
becomes set to the SelectedValue of the second list.
I'm also getting this exception during the render process: "A
DropDownList cannot have multiple items selected." I'm pretty sure this
is related to this problem.
The DDLs are named ddlSupervisorID1 and ddlSupervisorID2. Yes, I am
assigning the second supervisor before the first supervisor. This helps
illustrate the problem better. I'm having the same problem when the
first supervisor is assigned first.)
Any assistance is appreciated.
[begin output]
A: S1 = 0 | S2 = 0
S2: S1 = 0 | S2 = 4787
S1: S1 = 919 | S2 = 919
[end output]
[begin assignment code]
Trace.Write(ID, "A: S1 = " & ddlSupervisorID1.SelectedValue & " | S2 =
" & ddlSupervisorID2.SelectedValue)
'_ Supervisor2
ddlSupervisorID2.SelectedValue = data("SupervisorID2")
Trace.Write(ID, "S2: S1 = " & ddlSupervisorID1.SelectedValue & " | S2 =
" & ddlSupervisorID2.SelectedValue)
'_ Supervisor1
ddlSupervisorID1.SelectedValue = data("SupervisorID1")
Trace.Write(ID, "S1: S1 = " & ddlSupervisorID1.SelectedValue & " | S2 =
" & ddlSupervisorID2.SelectedValue)
[end assignment code]
[begin list construction code]
For Each dr As DataRow In dtAssociates
Dim sKey As String = dr("AssociateNameLF") & " (#" &
dr("AssociateID") & ")"
Dim li As New ListItem(sKey, dr("AssociateID"))
ddlAssociateID.Items.Add(li)
If dr("IsSupervisor") Then
ddlSupervisorID1.Items.Add(li)
ddlSupervisorID2.Items.Add(li)
End If
Next
[end list construction code]