473,769 Members | 2,249 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

When I set the DropDownList.Se lectedIndex of ONE DropDownList they ALL change!

S_K
Hi,

I have a list of 6 DropDownList boxes, from DropDownList1 to
DropDownList6, and I'm changing the SelectedIndex of each using a
foreach loop as follows:

foreach(Payment ReqDisplay thispayment in listPaymentReqD isplay)
{
if ((string)thispa yment.TaxType == "FIT")
this.DropDownLi st1.SelectedInd ex =
(int)thispaymen t.PaymentRequir ementID - 1;
if ((string)thispa yment.TaxType == "FUI")
this.DropDownLi st2.SelectedInd ex =
(int)thispaymen t.PaymentRequir ementID - 1;
if ((string)thispa yment.TaxType == "SIT")
this.DropDownLi st3.SelectedInd ex =
(int)thispaymen t.PaymentRequir ementID - 1;
if ((string)thispa yment.TaxType == "SUI")
this.DropDownLi st4.SelectedInd ex =
(int)thispaymen t.PaymentRequir ementID - 1;
if ((string)thispa yment.TaxType == "ETF")
this.DropDownLi st5.SelectedInd ex =
(int)thispaymen t.PaymentRequir ementID - 1;
if ((string)thispa yment.TaxType == "SDI")
this.DropDownLi st6.SelectedInd ex =
(int)thispaymen t.PaymentRequir ementID - 1;
}

The problem is that when I change, say, DropDownList4.S electedIndex =
3; every other DropDownList's SelectedIndex changes as well!?

What am I doing wrong?

Thanks much for your help.
Steve

Nov 13 '07 #1
3 1905
Do all ddls share the same items?

When you set the SelectedIndex property, it actually sets the Selected
property of the item you select. Thus the same item becomes selected in all
ddls it is participating.

The solution is to replicate the item collection for every single ddl.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"S_K" <st***********@ yahoo.comwrote in message
news:11******** **************@ 22g2000hsm.goog legroups.com...
Hi,

I have a list of 6 DropDownList boxes, from DropDownList1 to
DropDownList6, and I'm changing the SelectedIndex of each using a
foreach loop as follows:

foreach(Payment ReqDisplay thispayment in listPaymentReqD isplay)
{
if ((string)thispa yment.TaxType == "FIT")
this.DropDownLi st1.SelectedInd ex =
(int)thispaymen t.PaymentRequir ementID - 1;
if ((string)thispa yment.TaxType == "FUI")
this.DropDownLi st2.SelectedInd ex =
(int)thispaymen t.PaymentRequir ementID - 1;
if ((string)thispa yment.TaxType == "SIT")
this.DropDownLi st3.SelectedInd ex =
(int)thispaymen t.PaymentRequir ementID - 1;
if ((string)thispa yment.TaxType == "SUI")
this.DropDownLi st4.SelectedInd ex =
(int)thispaymen t.PaymentRequir ementID - 1;
if ((string)thispa yment.TaxType == "ETF")
this.DropDownLi st5.SelectedInd ex =
(int)thispaymen t.PaymentRequir ementID - 1;
if ((string)thispa yment.TaxType == "SDI")
this.DropDownLi st6.SelectedInd ex =
(int)thispaymen t.PaymentRequir ementID - 1;
}

The problem is that when I change, say, DropDownList4.S electedIndex =
3; every other DropDownList's SelectedIndex changes as well!?

What am I doing wrong?

Thanks much for your help.
Steve

Nov 14 '07 #2
S_K
On Nov 14, 2:52 am, "Eliyahu Goldin"
<REMOVEALLCAPIT ALSeEgGoldD...@ mMvVpPsS.orgwro te:
Do all ddls share the same items?

When you set the SelectedIndex property, it actually sets the Selected
property of the item you select. Thus the same item becomes selected in all
ddls it is participating.

The solution is to replicate the item collection for every single ddl.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net

"S_K" <steve_kers...@ yahoo.comwrote in message

news:11******** **************@ 22g2000hsm.goog legroups.com...
Hi,
I have a list of 6 DropDownList boxes, from DropDownList1 to
DropDownList6, and I'm changing the SelectedIndex of each using a
foreach loop as follows:
foreach(Payment ReqDisplay thispayment in listPaymentReqD isplay)
{
if ((string)thispa yment.TaxType == "FIT")
this.DropDownLi st1.SelectedInd ex =
(int)thispaymen t.PaymentRequir ementID - 1;
if ((string)thispa yment.TaxType == "FUI")
this.DropDownLi st2.SelectedInd ex =
(int)thispaymen t.PaymentRequir ementID - 1;
if ((string)thispa yment.TaxType == "SIT")
this.DropDownLi st3.SelectedInd ex =
(int)thispaymen t.PaymentRequir ementID - 1;
if ((string)thispa yment.TaxType == "SUI")
this.DropDownLi st4.SelectedInd ex =
(int)thispaymen t.PaymentRequir ementID - 1;
if ((string)thispa yment.TaxType == "ETF")
this.DropDownLi st5.SelectedInd ex =
(int)thispaymen t.PaymentRequir ementID - 1;
if ((string)thispa yment.TaxType == "SDI")
this.DropDownLi st6.SelectedInd ex =
(int)thispaymen t.PaymentRequir ementID - 1;
}
The problem is that when I change, say, DropDownList4.S electedIndex =
3; every other DropDownList's SelectedIndex changes as well!?
What am I doing wrong?
Thanks much for your help.
Steve- Hide quoted text -

- Show quoted text -
So you are saying that by setting the SelectIndex of (say) the first
ddl ALL of the ddls in that group get set along with it?
So how do I replicate the item collection for every single ddl? I
don't understand what you mean. Could you give me a code example?

Thanks so much for your help.
Steve

Nov 14 '07 #3
I mean every ddl should have it's own item collection, not shared with the
other ddls.

How do you populate the ddls?

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"S_K" <st***********@ yahoo.comwrote in message
news:11******** *************@2 2g2000hsm.googl egroups.com...
On Nov 14, 2:52 am, "Eliyahu Goldin"
<REMOVEALLCAPIT ALSeEgGoldD...@ mMvVpPsS.orgwro te:
>Do all ddls share the same items?

When you set the SelectedIndex property, it actually sets the Selected
property of the item you select. Thus the same item becomes selected in
all
ddls it is participating.

The solution is to replicate the item collection for every single ddl.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP
[ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net

"S_K" <steve_kers...@ yahoo.comwrote in message

news:11******* *************** @22g2000hsm.goo glegroups.com.. .
Hi,
I have a list of 6 DropDownList boxes, from DropDownList1 to
DropDownList6, and I'm changing the SelectedIndex of each using a
foreach loop as follows:
foreach(Payment ReqDisplay thispayment in listPaymentReqD isplay)
{
if ((string)thispa yment.TaxType == "FIT")
this.DropDownLi st1.SelectedInd ex =
(int)thispaymen t.PaymentRequir ementID - 1;
if ((string)thispa yment.TaxType == "FUI")
this.DropDownLi st2.SelectedInd ex =
(int)thispaymen t.PaymentRequir ementID - 1;
if ((string)thispa yment.TaxType == "SIT")
this.DropDownLi st3.SelectedInd ex =
(int)thispaymen t.PaymentRequir ementID - 1;
if ((string)thispa yment.TaxType == "SUI")
this.DropDownLi st4.SelectedInd ex =
(int)thispaymen t.PaymentRequir ementID - 1;
if ((string)thispa yment.TaxType == "ETF")
this.DropDownLi st5.SelectedInd ex =
(int)thispaymen t.PaymentRequir ementID - 1;
if ((string)thispa yment.TaxType == "SDI")
this.DropDownLi st6.SelectedInd ex =
(int)thispaymen t.PaymentRequir ementID - 1;
}
The problem is that when I change, say, DropDownList4.S electedIndex =
3; every other DropDownList's SelectedIndex changes as well!?
What am I doing wrong?
Thanks much for your help.
Steve- Hide quoted text -

- Show quoted text -

So you are saying that by setting the SelectIndex of (say) the first
ddl ALL of the ddls in that group get set along with it?
So how do I replicate the item collection for every single ddl? I
don't understand what you mean. Could you give me a code example?

Thanks so much for your help.
Steve

Nov 14 '07 #4

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

Similar topics

3
43411
by: Northern | last post by:
I have an ASP DropdownList populated. What I want is to select a new item, in my code, by set a datavale to dropdownlist's selectedItem.Value property. I did the following: MyDropdown.SelectedItem.Value = "value 1" Even though the "value 1" is in the dropdownlist's data value collection, the dropdown's datatext doesn't change.
5
2416
by: Dan | last post by:
Hi, I'm going crazy here, please help. I have a parent page that has a user control on it that bubbles up data from a dropdown menu. The drop down menus are populated by a set of radio buttons, each populates the drop downs with unique data. All works well, you check a radio button and the onbubbleevent fires loading the drop downs. A user can then select an item from the drop down and be forwarded (Respose.Redirect) to the appropriate...
1
1664
by: Nathan Sokalski | last post by:
I have a problem that is driving me crazy. I have a User Control composed of three DropDownLists that will be used to select a date. I have everything working except for one thing. When I select a new value from one of the DropDownLists, the code still returns the old value. You will notice that I try to access the SelectedIndex property in DateChanged, which is the eventhandler for all three SelectedIndexChanged events, although I could put...
4
2011
by: Mark Waser | last post by:
I've discovered a very odd bug when attempting to put a dropdown list in a datagrid. In the page PreRender step, the selected index of the datagrid is successfully set during databinding. Yet, when the datagrid enters it's own OnPreRender, the selected index has reverted to zero. I created a debug version of the dropdown list which inherited from dropdownlist and overrode the selected index property to trace.write whenever it was...
1
2032
by: DJ | last post by:
I have a DropDownList in Visual Web Developer that is databound to a SQL Database. Whenever the web page is opened the DropDownList is automatically filled with the first item in the table. My question is, how do I set it so that the DropDownList is empty until a value is selected?
1
7237
by: Jason Wilson | last post by:
I have two dropdownlists that are bound to the same datasource and I have a couple of questions: 1) Because they are bound to the same datasource, I am assuming that they only make 1 round trip to the DB server -- is that correct? 2) On a user's click of a button, one of the actions in the button OnClick event is to set the selectedindex of the 2nd DDL to that of the 1st. I get a runtime error here that says that the given index is...
11
4476
by: harold.gimenez | last post by:
Hi group, I am trying to change the selection of an ASP Dropdownlist just like "Orange" is selected here: http://www.w3schools.com/js/tryit.asp?filename=try_dom_option_selected The following works fine on IE: document.getElementById('dropdown').options.selected = 0 //
6
1860
by: Jonathan Wood | last post by:
I have a databound dropdownlist control. Based on some other criteria, I need to specify the selected item in my pages Load event. The problem is that, in my load event, the control does not yet have any data. I've found I can call DataBind() on that control and then it works okay. However, this has me wondering where the control normally databinds, and if me doing it manually would actually introduce the overhead of having the control...
0
1253
by: Bobby Edward | last post by:
Pretty simple webform layout... - Categories dropdownlist (used as a filter for gridview): ddlCategory - Gridview - DetailsView used ONLY for insert into the Gridview (All of this is contained in an UpdatePanel - using Ajax) In the InsertTemplate of the DetailsView I use a dropdown for "Category". I want it to ALWAYS be the same as the Categories dropdownlist at the top of
0
9590
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10051
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...
1
10000
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9866
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
8879
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...
0
5310
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3968
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
3571
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.