SelectedIndexChanged propagates between Columns (?!)

B

Brock Allen

Did you disable viewstate form the DDLs? If so, then you will see odd behavior
when you are handling their SelectedIndexChange events. The gist of it is
that they need ViewState enabled to keep track of the last index so they
can know if the posted index is diifferent.
 
E

Eliyahu Goldin

My guess is your ddls share the same items. Right? When you have that,
changes in one ddl affect another one via common item objects that they
share.

Eliyahu
 
U

Uri

Hi,

I have a DataGrid with two Template Columns - each contains a DropDownList.
Both DDLs are set to AutoPostBack and the first DropDownList has a
SelectedIndexChanged event handler attached to it.

Oddly enough, when I change the value of the _second_ DDL, when the PostBack
is performed, the event handler for the _first_ DDL is called - by the first
DDL.

How come the change in the second DDL triggered the first DDL to fire the
event and handle it? Can I stop this from happening? I only need the first
DDL to
trigger the event.


Thanks in advance,
urig.
 
U

Uri

Hi,

Please disregard my pervious request for help.The reason for the odd
behavior I mentioned
was a bug in my code :(.

I had forgotten that I had assigned the event handler to both the
SelectedIndexChanged
event and to the OnLoad event for the first DDL.

So when a PostBack was performed, the event handler was called when the
first DDL was
loaded, regardless of which control caused the Post Back.


urig.
 

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

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top