[quoted text, click to view] "Shawshank" <shutterfly@gmail.com> wrote in message
news:eYQ$lxl5EHA.3828@TK2MSFTNGP09.phx.gbl...
>I am nearly desperate. Hope anyone of you can help.
>
> In my web application, I need to use several interdependent DropDownLists,
> which means contents and selections of one dropdownlist depends on
> slection in another. Initially I used server side OnSelectionChange event
> handler of one dropdownlist to populate the other dropdownlist . it
> workded well functionally but the postback is really distracting.
> So I used client side javascript to populate the client control of the
> dropdownlist (( of course with a little pain by getting the ClientId on
> server side and pass it to the Javascript so that JS knows which control
> to insert options). It worked fine on the client side, but the server
> cannot pick up the changes (new Items, and SelectedValue, SelectedIndex,
> etc. It seems server is ignoring any change JavaScript makes. ) user made
> on the client after user click "submit".
>
> I have been stuck on this for two days, and please help!
If you turn on page tracing, and look at the values posted back by the form,
you'll notice that the added values are not posted back. In fact, HTML never
posts back anything from a <select> other than the selected value. There's
nothing for the server side to look at.
The only workaround to this is to put the added stuff somewhere the server
side _can_ see. For instance, you can create a hidden input field and put
the added values there. The server side can then look in the hidden field
(which will be posted back) to see what got added.
The other thing you may be able to do depending on the nature of your data
is to send all of the possible values to the client side and to allow the
client side to choose which values will be used. As an example, I once had a
dropdownlist of US states and one of Canadian provinces, and displayed one
or the other (or neither) depending on the Country chosen in another
dropdown list.
John Saunders