473,756 Members | 1,842 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Two DropDownLists getting crossed

Jay
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]

Nov 19 '05 #1
2 1215
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("AssociateNa meLF") & " (#" &
dr("AssociateID ") & ")"
Dim li As ListIten

li=New ListItem(sKey, dr("AssociateID "))
ddlAssociateID. Items.Add(li)

If dr("IsSuperviso r") Then

li=New ListItem(sKey, dr("AssociateID "))
ddlSupervisorID 1.Items.Add(li)

li=New ListItem(sKey, dr("AssociateID "))
ddlSupervisorID 2.Items.Add(li)

End If
Next
"Jay" <sp**@bienvenu. net> wrote in message
news:11******** **************@ g44g2000cwa.goo glegroups.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 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]

Nov 19 '05 #2
Jay
Is there a cleaner way to do this? Copying the line "li=New
ListItem(sKey, dr("AssociateID "))" will clutter the code unnecessarily.

Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2129
by: theo | last post by:
Hello..I have a similar issue as yesterday but the situation has slightly changed so perhaps someone can shed some more light on the issue... Program flow - load file,extract xml text tags from file,then depending on the number of Xml tags retrieved from the file determines the number of dropdownlist controls instanciated in the placeholder,the user selects the required tags from the dropdownlists (if 5 Xml tags,then 5 dropdownlists...
1
1224
by: Chris | last post by:
Hello All, Need some help here. I'm building an asp.net app that uses a datagrid. I have created a template column and added a dropdownlist to it. What I'd like to happen is have the database get updated each time the user selects a different value from the dropdownlist without having to press a submit button or anything. I've been trying to get it to work when the SelectedIndexChanged event fires off but with the AutoPostBack = TRUE,...
0
1399
by: Steve Caliendo | last post by:
Hi, I'm having trouble with multiple dynamically generated dropdownlists. On my web page I have several text boxes / labels / checkboxes and dropdownlists I have no problem setting the other controls to display what I would like them to, but the dropdownlist boxes are simply not working. I can't set the selectedindex to be different for each of the controls. What I'm doing is this:
9
5338
by: Timm | last post by:
I have an ASP.NET 2.0 page with two DropDownLists. I am using declarative data binding wherever possible and trying to minimize the use of code. The list of values in DropDownList DDL2 should be (filtered) dependent upon the selection in DDL1. I think this inevitably needs some code, but I'd be happy to be told otherwise! I have some code to handle OnSelectedIndexChanged for DDL1 that sets the FilterExpression associated with the...
2
10089
by: Italian Pete | last post by:
Hi, I have some dropdownlist web controls on as aspx page. I want to loop through them on first (!IsPostBack) Page_Load in order to populate them. The foreach control structure seems to be a good condidate for this though I'm having problems getting the right syntax/form. I've been trying variations on the following: foreach (DropDownList myDDL in Controls) { //do something here
8
1571
by: MattB | last post by:
I have a asp.net 1.1/vb application that has a page with a bunch of dynamically added User Controls. When I add the controls, I set the UserControl.EnableViewState to true. For all my controls with TextBoxes, I can get the value back out of the controls just fine. One of my User Controls has some DropDownLists as well as a TextBox. I get a value from the TextBox on postback, but not the DropDownLists. Even if I see a value selected when...
0
1132
by: Carlos | last post by:
Hi all, I just embedded a dropdownlist templatefield inside a gridview. When I look at the control in design mode, I see 5 dropdownlists, when I bind the data to the gridview, I only bind to 3 dropdownlists. How can the number of controls that are itemtemplates can be controlled? That is, if in fact I want to display 5 dropdownlists containing the same data ?
3
1649
by: RSH | last post by:
Hi, I am having this very bizarre occurance with 4 dropdown lists on my ASP .Net page. Each control has its own unique id. When the user selects a value from each of the dropdownlists it is written correctly to the database. HOWEVER...When setting the SelectedIndex property of each of the controls in the codebehind (.net 1.1) I get an exception "A dropdownlist can not have
1
1308
by: klaul | last post by:
I've been trying to do this for a day and a half now, and am clearly getting nowhere! The database I'm using is used to keep a log of service calls to various companies. When the user inserts data, they choose the company from a static list, but the reference number is user-supplied. The data is brought back using a GridView. I am trying to create two linked dropdownlists so that I can search the gridview (so that the items on the second...
0
10034
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9872
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9713
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8713
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7248
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3805
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3358
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.