473,769 Members | 1,632 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Drop down list selected value not submitting

Hi there

I am populating an empty <asp:dropdownli st on the client side using
Javascript using the following code

Heres my dropdown list
<asp:dropdownli st id="ddlDealers " Runat="server"> </asp:dropdownlis t>

heres the Java
var myDropDownList = frmMain.ddlDeal ers;

for (var cnt=0;cnt<=deal ers.length-1;cnt = cnt + 2){
var opt = new Option(dealers[cnt],dealers[cnt],0,0);
myDropDownList. options[myDropDownList. options.length] = opt;
}
where dealers() is an array of values

the list is populated correctly and it all looks fine
my problem is that when I post the page using a <:asp Button the
selected value of the list is not being picked up on the server. Lets
say I selected 'Steve' in my drop down list, a simple test in my
Page_onload as follows returns NULL.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Response.Write myDropDownList. SelectedValue
End Sub

The only time I can get the selected value from a dropdown is when I
have populated the drop down at the server in the normal .NET fashion,
but this requires an extra trip to the server which I am trying to
avoid.

Any ideas??

Mark

Feb 15 '06 #1
4 9180
Have you tried using

Request.Form("m yDropDownList")

I have had issues with postbacks and grabbing .SelectedValue from a DD.
Request.Form always seems to help in those weird situations.

Hope it helps,
Jeremy Reid
http://blackstaronline.net

Feb 15 '06 #2
Hey that works thanks.

I guess because the Drop down list items aren't created on the server
side the client side selected item does not match with the server side
data, or something like that. Meaning you have to revert to a more
classic ASP style Request.Form

Thanks
Mark

Feb 15 '06 #3
It's because with dynamically added options, such as that, are not
persisted in ViewState, so the DDL control doesn't actually know
anything about those members.

When you post back, it parses the view state to look for the value you
are looking for. Request.Form gets the post variables, rather than
matching the posted selected value to the value in view state.

Feb 15 '06 #4
thanks for the info

So if I want to dynamically populate drop down lists, is using
Request.Form the best method to use or is there a more elegant
solution. I am using Callback to retrieve the list data from the
server

var xmlRequest = new ActiveXObject(" Microsoft.XMLHT TP");
etc..

can the viewstate be updated during this callback to the server?

Feb 16 '06 #5

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

Similar topics

7
6600
by: deko | last post by:
I populate a drop-down list like this: echo "<select>"; foreach ( $ip_list as $var ) { echo "<option>"; echo $var; echo "</option>"; } echo "</select>";
46
5143
by: Kingdom | last post by:
In my data base I have a list of componet types e.g. type A - I have 8 off - type B I have 12 off etc. I'm using Set objRS = objDC.Execute("Select DISTINCT Component_Type FROM Parts_Table") to populate a drop down but would like to use several drop downs restricting the contents of each drop down to the records pertaining to one
2
13313
by: Patrick | last post by:
Hello, I have a drop down list that when a value is selected the page refreshes itself but the selected value changes back to the default value. I would like to keep the selected value after the page is refreshed. any ideas? Thanks in advance. Patrick
4
6315
by: Dan | last post by:
Can anyone offer suggestions on how to do this or if it is possible? I have a form that uses a drop down box and 2 text fields. What I am trying to do is have the value of each text box set by the choice from the drop down box. Something like: <form name="populatefrm" id="contactfrm" method="post"
1
2913
by: Dan | last post by:
This is one that has me stumped and I need an expert's input. Any ideas why the values from the second script-generated drop down list isn't recognized by the script to add time values to the text boxes? What this script is suppose to do is change the value of a second drop down list based on the selection from the first. Then a value is chosen from the script generated drop down list in the
2
12622
by: Yoshitha | last post by:
hi I have 2 drop down lists in my application.1st list ontains itmes like java,jsp,swings,vb.net etc.2nd list contains percentage i.e it conatains the items like 50,60,70,80,90,100. i will select any skill in 1st drop down list then i'll select % of this skill in the 2nd list box , based on the percentage i've selected in the 2nd list box it has to display 2 sets of drop down list boxes at run time one for selecting skill and
5
4230
by: Vigneshwar Pilli via DotNetMonster.com | last post by:
string connectionString1 = "server=(local); user=sa;password=sa; database=sonic"; System.Data.SqlClient.SqlConnection dbConnection1 = new System.Data.SqlClient.SqlConnection(connectionString1); System.Data.SqlClient.SqlCommand dbCommand1 = new System.Data.SqlClient.SqlCommand();
3
2996
by: John Walker | last post by:
Hi, On an ASP.NET page I have a drop down list control. When the user pulls down the list and makes a selection, I perform validation, and if the validation fails I want the selected item in the drop down box to go back to what the value was before the user tried to change it, but at that point I will not know what the original value was. Or is there a drop down control "revert" method, or is there any way of knowing what the original...
2
3094
by: giandeo | last post by:
Hello all, It's almost a couple of weeks since i am struggling to get this code work. Unfortunately, i am stuck. There seems to be no hope... Please Help....... I am working with an asp page that dynamically pulls info from my database to populate a drop down menu. Upon an onChange event, I wish to display the fields related to that pull down menu WITHOUT SUBMITTING THE PAGE. The Senario: Database name: sp.mdb
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9863
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8870
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7408
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6673
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3958
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 we have to send another system
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.