|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Two DropDownLists getting crosseda 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] You only created ONE ListItem, but tried to add it to 3 dropdown list. You
should create ListItem for each Dropdownlist: For Each dr As DataRow In dtAssociates Dim sKey As String = dr("AssociateNameLF") & " (#" & dr("AssociateID") & ")" Dim li As ListIten li=New ListItem(sKey, dr("AssociateID")) ddlAssociateID.Items.Add(li) If dr("IsSupervisor") Then li=New ListItem(sKey, dr("AssociateID")) ddlSupervisorID1.Items.Add(li) li=New ListItem(sKey, dr("AssociateID")) ddlSupervisorID2.Items.Add(li) End If Next Show quoteHide quote "Jay" <spam@bienvenu.net> wrote in message news:1118431669.226338.218300@g44g2000cwa.googlegroups.com... > 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] >
Other interesting topics
Code-Behind Pain in the Behind!
Best way to disable a site? Is there server control that you load with HTML from a URL Options for generic full-text search without using database-specific full-text engine? Dynamically position custom control .ascx Message Box in ASP Firefox Validation Issue - not the standard document.[all] problem! Server.MapPath from a vb class validating How to hide aspx from URL in address bar |
|||||||||||||||||||||||