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 ddlSupervisorID 1 and ddlSupervisorID 2. 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 = " & ddlSupervisorID 1.SelectedValue & " | S2 =
" & ddlSupervisorID 2.SelectedValue )
'_ Supervisor2
ddlSupervisorID 2.SelectedValue = data("Superviso rID2")
Trace.Write(ID, "S2: S1 = " & ddlSupervisorID 1.SelectedValue & " | S2 =
" & ddlSupervisorID 2.SelectedValue )
'_ Supervisor1
ddlSupervisorID 1.SelectedValue = data("Superviso rID1")
Trace.Write(ID, "S1: S1 = " & ddlSupervisorID 1.SelectedValue & " | S2 =
" & ddlSupervisorID 2.SelectedValue )
[end assignment code]
[begin list construction code]
For Each dr As DataRow In dtAssociates
Dim sKey As String = dr("AssociateNa meLF") & " (#" &
dr("AssociateID ") & ")"
Dim li As New ListItem(sKey, dr("AssociateID "))
ddlAssociateID. Items.Add(li)
If dr("IsSuperviso r") Then
ddlSupervisorID 1.Items.Add(li)
ddlSupervisorID 2.Items.Add(li)
End If
Next
[end list construction code]