views:

357

answers:

2

I'm quite confused by something. I've got 2 select lists, and if you choose an option in the first, I then load the 2nd with a certain set of options. I clear this out and repopulate it every time you change the selection in the first select element. Now, on postback, I need to know the value of the option that was selected in the 2nd select element, but it is always showing up as -1.

I'm sure I'm missing something fundamental and dumb on my part, but can anyone point me in the right direction?

+2  A: 

I don't actually see the code, but what is probably happening is that you are clearing it before actually looking at the value, probably in your Page_Load.

stephenbayer
Interesting. I'll check that now -- thanks!
Matt Dawdy
Yes. My own stupid fault. Thanks for the pointer. I was looking over "everything!" Sometimes you just need a new pair of eyes, or a very good suggestion from stephenbayer.
Matt Dawdy
+1  A: 

Did you say you were adding items to the right hand list using client side code rather than server side code?

If so you will need to capture the form items being posted manually (Request.Form) and populate the listitem with these new details. Or at least that is what I remember off the top of my head.

If you post some more details about if it is a server side or client side addition to the listbox I'm sure someone with a bit more time can give you the answer.

John_
Yup -- adding them client-side only. I was, for some idiotic reason, clearing out the list before checking it on postback, though. Thanks for the suggestion.
Matt Dawdy