Odd Dropdownlist problem

B

bull2000

we have two dropdownlist controls in a program. both of them have the same
data items in the list.
these dropdownlists are populated in Page_Load and set selected value using
SelectedValue.
the odd thing is when one is changed the other one will be changed as well.

NewBranch.SelectedValue = (string)dr["NewBranch"];
OldBranch.SelectedValue = (string)dr["OldBranch"];

It seems somehow the wire gets crossed. I checked the declaration and other
code and can not find anything wrong.
Any idea what could be wrong, where to look.

Thanks a lot for your help


PS. we have a working version of code and do not seem any difference between
the working version and the debuggy one.
 
H

Harolds

The problem is you populating the dropdowns with the same data. What I mean
is, when you populate the dropdowns the data is not copied to the controls
but a pointer is set to point to the data, so both controls are pointing to
the same data. It is hard to explain. But if you don't understand what I am
saying, post you code and I will try to use it to explain better.
 
B

bull2000

Harolds,
I understand what you mean. Thanks a lot.

Harolds said:
The problem is you populating the dropdowns with the same data. What I mean
is, when you populate the dropdowns the data is not copied to the controls
but a pointer is set to point to the data, so both controls are pointing to
the same data. It is hard to explain. But if you don't understand what I am
saying, post you code and I will try to use it to explain better.

we have two dropdownlist controls in a program. both of them have the same
data items in the list.
these dropdownlists are populated in Page_Load and set selected value using
SelectedValue.
the odd thing is when one is changed the other one will be changed as well.

NewBranch.SelectedValue = (string)dr["NewBranch"];
OldBranch.SelectedValue = (string)dr["OldBranch"];

It seems somehow the wire gets crossed. I checked the declaration and other
code and can not find anything wrong.
Any idea what could be wrong, where to look.

Thanks a lot for your help


PS. we have a working version of code and do not seem any difference between
the working version and the debuggy one.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top