473,395 Members | 1,639 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

DropDownList always returns value at index 0

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
4 1614
"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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Earl Teigrob | last post by:
I want to write a function where I pass in a reference to a dropdownlist and a "match value" and have it returns the index of the dropdownlist item that matchs (or -1 if there is no match) ...
7
by: Lastie | last post by:
Hi all, I’ve got a ‘dropdownlist’ web control and I can add ‘listitem’ no problem. I can also bind data from an SQL database fine. My problem is that I want to do both at the same...
3
by: Richard | last post by:
I've seen articles on GotDotNet and elsewhere on how to put a ddl in a datagrid, and have been able to implement this technique. For a new item, among the datagrid columns there is the one ddl for...
3
by: Siamak Zahedi | last post by:
Hi, weird problem I'm having cant seem to figure out what is going on. I have a dropdownlist that gets populated from db and a button that causes a post back when I assign the value of the...
3
by: Olivier Verdin | last post by:
Hi, I have a page with several Textboxes and several DropDownList. When I click on a 'save' button, it creates a record in a database. The page works fine under Internet Explorer. It does...
0
by: Gunjan Garg | last post by:
The issue here is - When the postback event happens the selected index is always returing the first value. Appreciate your help in advance. Thanks Here is the code...
4
by: Mark Waser | last post by:
I've discovered a very odd bug when attempting to put a dropdown list in a datagrid. In the page PreRender step, the selected index of the datagrid is successfully set during databinding. Yet,...
3
by: Nathan Sokalski | last post by:
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...
0
by: Moneypenny | last post by:
Hi there, I have a Gridview control which has a dropdownlist in every row. The dropdowns are populated dynamically from a database (so the content is different in each row. There is also a select...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.