473,671 Members | 2,557 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 1899
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
43405
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
2411
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
1657
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
2008
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
2028
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
7227
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
4461
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
1855
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
1246
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
8483
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
8927
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...
1
8605
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
8676
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
7445
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
5703
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();...
0
4227
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
4416
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1816
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.