473,508 Members | 2,454 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 21 '05 #1
3 1149
"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 21 '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 21 '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 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1193
by: John | last post by:
Hi, I have a dropdownlist with x amount of list items, however quite often a lot of the list items have the same value. The dropdownlist is bound to an ArrayList of objects and I'm using the...
3
2260
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
2017
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
1794
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
4141
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
2905
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
1010
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
1617
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...
4
2000
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,...
0
1773
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
7129
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
7333
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
7398
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7502
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...
0
5637
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4716
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3194
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1566
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
428
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.