By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,193 Members | 1,535 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,193 IT Pros & Developers. It's quick & easy.

DropDownList always returns value at index 0

P: n/a
I have a form that contains a DropDownList. When I submit the form and
attempt to use the DropDownList's value (I am doing this by using the
..SelectedValue property), I always recieve the value at index 0. What could
be causing this? Any help would be appreciated. Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/
Nov 19 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"Nathan Sokalski" <nj********@hotmail.com> wrote in
news:eS**************@TK2MSFTNGP14.phx.gbl:
I have a form that contains a DropDownList. When I submit the form and
attempt to use the DropDownList's value (I am doing this by using the
.SelectedValue property), I always recieve the value at index 0. What
could be causing this? Any help would be appreciated. Thanks.


Are you rebinding the drop down on each postback?
--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.

Newmarket Volvo Sucks! http://newmarketvolvo.tripod.com
Nov 19 '05 #2

P: n/a
Possibly you are filling the dropdown on postback also. Check it is done
only on initial page load:

If (Not PostBack) Then
// Fill drop-down
End If

"Nathan Sokalski" <nj********@hotmail.com> wrote in message
news:eS**************@TK2MSFTNGP14.phx.gbl...
I have a form that contains a DropDownList. When I submit the form and
attempt to use the DropDownList's value (I am doing this by using the
..SelectedValue property), I always recieve the value at index 0. What could
be causing this? Any help would be appreciated. Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

Nov 19 '05 #3

P: n/a
Nathan,

How did you fill your dropdownlist.
If that is by a datasource, did you than restore your datasource at PostBack
time?

\\\
If Not IsPostBack then
fill ds
Session.Item(ds) = ds
Else
ds = Session.Item(ds)
End if
////

And don't forget to databind it at the last instruction before your sent
back

I hope this helps,

Cor
Nov 19 '05 #4

P: n/a
Thank you all, I don't know why I keep making this same mistake. I simply
needed to put my binding method in the Page_Init instead of Page_Load. But
thank you for using the key word init that reminded me of the simple
solution that took me forever to find in the past.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/
"Lucas Tam" <RE********@rogers.com> wrote in message
news:Xn***************************@127.0.0.1...
"Nathan Sokalski" <nj********@hotmail.com> wrote in
news:eS**************@TK2MSFTNGP14.phx.gbl:
I have a form that contains a DropDownList. When I submit the form and
attempt to use the DropDownList's value (I am doing this by using the
.SelectedValue property), I always recieve the value at index 0. What
could be causing this? Any help would be appreciated. Thanks.


Are you rebinding the drop down on each postback?
--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.

Newmarket Volvo Sucks! http://newmarketvolvo.tripod.com

Nov 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.