HighTechTalks DotNet Forums  

dropdown losing selected index value

ASP.net Data Grid Control microsoft.public.dotnet.framework.aspnet.datagridcontrol


Discuss dropdown losing selected index value in the ASP.net Data Grid Control forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Steve Hershoff
 
Posts: n/a

Default dropdown losing selected index value - 11-10-2006 , 02:34 PM






Hi everyone,

I have a dropdown control in a DataList that for some reason "loses" its
index value during postback. I'm not quite sure why.

First, a little talk about the structure of the DataList: it has several
other dropdowns besides the one I'm interested in. One of them has its
index set to zero on every postback, no matter what, and in its
OnSelectedIndexChanged function it calls DataBind() on my troublesome
dropdown.

Think of it like two cascading dropdowns: dropdown A, and my dropdown B,
the misbehaving one. If dropdown A's index changes, it calls DataBind on
dropdown B. dropdown B uses a separate DataSource from the DataList,
created via a function that's listed declaritively in the aspx form.

So a typical use case involves my selecting a value from dropdown B, which
forces an automatic page postback. (Autopostback = true for the control) In
the Page_Load method the DataList is bound, which binds dropdown A, and as I
mentioned above, A's selected index is set to zero. This in turn fires off
dropdown A's OnSelectedIndexChanged function, which calls DataBind() on
dropdown B.

I don't know if doing that resets dropdown B's selected index value, but by
the time dropdown B's OnSelectedIndexChanged is finally called the
SelectedIndex property has been reset to zero, which is definitely *not* the
value I selected on the form. Does anyone know why this is, and how I can
hold the proper SelectedIndex value all the way through?

I realize my scenario above sounds is a little hard to digest, so any help
you can give would be greatly appreciated. I think the key question here
is: does calling DataBind() on a dropdown control invalidate the
SelectedIndex property set via a postback?




Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.