DropDownList always returns value at index 0

  • Thread starter Thread starter Nathan Sokalski
  • Start date Start date
N

Nathan Sokalski

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.
 
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?
 
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

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,

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
 
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.
 

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

Back
Top