Dropdown list only selects first value

I have a dropdownlist that is populated with from a common list. The control is populated correctly but when I submit the value is reset to the first Item in the list.

For example:
I have a dropdown with the following values

  • value1
  • value2
  • value3
No matter which item I select the value saved to the database is value1.
What am I doing wrong?

Fixed this one myself.  Left databind outside postback conditional statement.  Couldn't see the forest for the trees.

0
Jterhune
6/6/2005 5:42:48 PM
asp.net.dotnetnuke 25171 articles. 0 followers. Follow

3 Replies
611 Views

Similar Articles

[PageSpeed] 7

Hmmm. We're having a similar problem. We have a modified ContactUs module that allows the user to select a subject from a dropdown list. For some reason it always selects the first value in the list no matter what the user selected. But the really strange thing is that one internal user who tries it on the same page/module works fine. I thought it might be a browser issue since I was using FireFox and him, IE but it's not. Another tester using IE has the same issue. So for some reason for most users it's reseting or not saving the selected value of the dropdown but for at least one user it is. Any ideas on this?



Dan
0
DigitalMan
7/12/2006 1:23:35 PM
Ok, here it is. I knew this was a bug in FireFox way back but I also knew it worked fine in IE at the time. I even poseted to FireFox's bug tracker at the time. If you don't use unique values in your dropdown list it can cause this bug to appear. At the time it seemed as though FireFox was re-populating the control after a postback using the value instead of the index and that IE correctly used the index. Now it seems IE has the same problem. Being in a DNN module I'm also wondering if the nesting of the control could bring about the issue. For an example say you have a dropdown list with 3 items, "Sub1", "Sub2", and "Sub3" and the value is set to the same thing for each one, let's say an email address. No matter which item you pick, after postback it sets the selected item to Sub1. If we change it to use ID's for the value and then query the database for the email after the postback it then works. But I can see a lot of situations where you may want to have the same values for more than one item. Very strange. Has anyone else run into this before?



Dan
0
DigitalMan
7/12/2006 4:02:56 PM
This makes sense to me now. Posting the form causes the value to be passed not the index. I guess what I was thinking of with the firefox bug was that if you used the back button to go back to the form it would not set the correct item if values were not unique but in IE it did. Still not sure why on one pc running IE we cannot reproduce the current issue though.

Dan
0
DigitalMan
7/12/2006 4:26:52 PM
Reply:

Similar Artilces:

Cascading Dropdown List
Hi, First post so hello and need some help with an issue I have been dealing with.  I have an intranet page I created in ASP.NET using C# .NET 3.5 with a few Ajax Extenders including 3 Cascading Dropdown Lists. Now I have used the Cascading dropdown lists for my own purposes i.e they do not actually cascade their results to another dropdown list, the reason I did this was due to the having a User Control that contains an update panel and other bits i.e I didn't want the control/page posting page (something that happens when you click on a regular dropdown list). Everything is wor...

DropDown list submits first value not the selected value
I am relatively new to programming and am having a problem with a small project that I am working on.  I have a names drop down list that is created from a database.  When the user selects a name and completes the rest of the form and clicks submit.  All of the data they entered is submitted to a different table in that database.  This is workign correctly for all of the data except the drop down.  For some reason the first value in the drop down is being submitted each time.  Here is the code and any help you can give will be appreciated. Public Class final1 ...

Dropdownlist selected value passes first value in list no matter what value is selected. why ?
 HI . I have a dropdownlist. Databinds ok but when I must pass a value as a Selected value it always passes the first value in the list even if I select another value. I tried to set the ddl to enableviewstate false but it doesn't change anything. Any ideas ? Code below, thanksLoading the ddl:       productCategories = CatalogAdmin.Admin_Product_Categories_NotIn(productId);        for (int i = 0; i < productCategories.Rows.Count; i++)        {       &...

How to get value from first dropdown list to second dropdown list
Hi Does soneone know hot to get value from first dropdown list to second dropdown list or remove it from seond dropdown list? I have a web form page. On the page, there are two dropdown lists, one Add button, and one Remove button . First dropdown list has four list items. Second one does not have list item yet. When select a item from first dropdown list, then click "add" button. I want it to apear in the second dropdown list without reload the page. Or select item from second dropdown list, and click "Remove" button. it will remove from second list. Please help. &nb...

Populate dropdown list based on selected value in another dropdown list
I have a datagrid (grdCar) that contains two dropdown listboxes (ddlCarManf and ddlCar). When the user clicks the "Edit" link and places the grid into edit mode, they select a value in ddlCarManf. Based on the selected value in ddlCarManf, I need to then populate ddlCar with a list of cars for which the selected manufacturer makes (I'm using ddlCarManf.SelectedValue to query the database).  I bind my datagrid in the page_load event as: If Not Page.IsPostBack Then    BindGrid() End If Here is my control (ddlCarManf) as is appears within grdCar in ...

first selected value disappears from dropdown list
With the following code, the initial index of 0 disappears from ddlGroups when the selected value changes. Any suggestions?     Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load        Dim strSQL As String = "W_SP_SELECT_GROUPS"        ddlGroups.Visible = True        lblUsers.Visible = False        ddlUsers.Visible = False        ddlUsers.Sele...

Getting the selected value of the first databound item in a dropdown list
Does anyone know how to get the SelectedValue out of the drop down list if the First Item is selected within the list.  The only way I know of doing this is by putting a button there and giving the user the option of pressing the button as well as selecting from the list.  RegardsRB Have you contemplated setting 'AutoPost=true' and having the DDL invoking the OnSelectedItemChanged Event on the server?RegardsAndre Colbiornsen ---------------------------------Seventh DayRåbygatan 1A,SE-223 61 LundSwedenMob.: +46-(0)708-97 78 79Mail: info@seventhday.se-------------------------------...

About dropdown list selected item and selected value
hi to all i have one table. that have albhapetic list of countries name and country id. i want to bind country table to dropdownlist. dropdownlist text field is country name the value field country id.the dropdown list heading is "-- select country--". but page load time i want load default country is INDIA and value is ind. guide me how achieve this scnario. You can write following line in Page load event.ddCountryDropDownList.SelectedValue = "ind";Hope this helps! Programmers are tools for converting caffeine into codeVisit my blog Try this way insteadDropDown...

adding values to the selected value in Dropdown list
 Hi,   I have dropdown box in my page which have some value inherted from the another list box in my page..Now in my second page , i have dropdown box with values and text value and list box... I'll be selecting the one value from the dropdown then i enter the value in text box and click on add button which will add the value in the list box like this i can able to add many value...now if i click on save button for the selected dropdpown item the added values in the listbox should be saved ...like this i add many values for many dropdown item and saved respectivelynow if c...

How to get the list of second drop-down-list based on value selected in the first drop-down-list
I have two drop-down-lists, the second one depends on the value chosen in the first drop-down-list.  In the first drop-down-list, I have AutoPostBack = "true" and OnSelectedIndexChanged = "SelectedIndexChanged" In the selectedIndexChanged method, I do the following: 1    protected void SelectedIndexChanged(object sender, EventArgs e)2        {3            if (IsPostBack)4            {5      &nbs...

How to show value in textbox from selected value in Dropdown list
I have two text box, txtbox1 should be from two field for example i have one dropdownlist where i select item and another txtbox2 i want to put value, when i first time to write manually value in txtbox2 in and selected item from ddl i want to result in concatenate from in txtbox1. for example  I haveif not me.ispostback thenDim cm as new sqlcommand("Select AccMjrid, Names from Accgrp", me.sqlconnection1.open())me.sqldataAdapter1.fill(Dataset1, "Accgrp") Me.cmbAccMajID.DataSource = Me.DataSet11.Tables("AccMajor") Me.cmbAccMajID.DataTextField = "AccName" Me.cmbAccMajID.DataValueField ...

dropdown selected value and dropdown no value saved
 is there any way the selected value is selected already when i try to edit the gridview ... and another thing... when i edit this dropdown.. no value was being saved... what is wrong or missing.. please help... i almost spend two days on this problem...i've read many post about this.. but still i didn;t get it... please help///  <asp:TemplateField HeaderText="Unit" SortExpression="UnitID">                          &...

changing the selected value for the dropdown list to match a query string value
My url looks something like this "http://www.imaslog.com/real_world/send_messages.aspx?recipient=cheatcountry and on that page I want the dropdownlist selected value to show up as cheatcountry automatically if that is what the query string is. How do i do this? Hi, QueryStrings can't be read via javascript. If your select box (combo box) is a html control and not DropDownList server control. You do a normal static variable to set the selected property in the combo box to this variable. You then use the server side to read the query string and pass the selected value to this j...

Displaying values from 3 textboxes automatically after selecting a value from a dropdown list
 The dropdown list is databind to a sqldatasource from the Bike Table.After selecting a bike Name from the dropdown list, the status and rent price will be displayed on the 2 textboxes automatically.Both the status and  rent price values are taken from the same Bike Table.Can anyone help me with this?Thanks. On the selected index change property of the dropdownlist hit the database to get the details (status and rent ) for the selected Item and set the values to the text of textboxes.Hope this helps. Just do this in your OnSelectedIndexChanged event of the ddlSqlCommand cmd =...

Web resources about - Dropdown list only selects first value - asp.net.dotnetnuke

How to convert unordered list into nicely styled <select> dropdown using jquery?
$('ul.selectdropdown').each(function(){ var select=$(document.createElement('select').insertBefore($(this).hide(); $('>li a', this).each(function(){ ...

Credit Suisse Reiterates On Enbridge Energy Partners, L.P. Following Alberta Dropdown
In a report published Thursday, Credit Suisse analyst John Edwards reiterated an Outperform rating on Enbridge Energy Partners, L.P. (NYSE: EEP), ...

Convert a Menu to a Dropdown for Small Screens
Create a menu that, on smaller screens, changes into a dropdown menu. A dropdown takes up much less screen real estate and can be easier to use. ...

Office-Add-in-Fabric-UI-Sample/Dropdown-demos.html at master · OfficeDev/Office-Add-in-Fabric-UI-Sample ...
Contribute to Office-Add-in-Fabric-UI-Sample development by creating an account on GitHub.

Google Adds Dropdown Menu to Search Results, Hides Cached Pages Inside
Google recently updated their search results format, again moving the link for cached page access somewhere else. Now it hides in a convenient ...

50+ Awesome jQuery Dropdown Menu Tutorials
When designing graphical user interfaces, many people prefer to use a dropdown menu as a GUI element. This allows the user to choose a value ...

Sign out command in dropdown
We can save some space in the menus by putting the Sign-out command in the dropdown menu. As we're building the menu, if I see a command called ...

Google toys with removing Instant Preview in Search, adds dropdown menu with Cached, Similar, Share options ...
Google has added a new drop-down menu to its search results page beside every URL with three options: Cached, Similar, and Share. At the same ...

Facebook Fan Page Changes You Haven’t Heard About
... fashion appears at the top center of the page if you scroll down to the cover image or any point lower. A box labeled highlights has a dropdown ...

Edit Companies - Eric Feng - CrunchBase Person Profile
If this person is an investor, please only submit companies for which he/she has a functional role (like Board, Advisor, etc). Click 'Past?' ...

Resources last updated: 11/22/2015 6:09:31 PM