473,383 Members | 1,742 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,383 software developers and data experts.

Drop Down List Control , Select Value, and Javascript

Hi,

I've been asked to create a page that dynamically populates the contents of
related drop down lists using JavaScript, and then obviously posts things
back to the server.

For completeness, I re-produce example JavaScript below (this seemingly
works fine - but just to let you see what is going on)

e.g. var categoriesArray = TrendCategoriesHolder[intTrendIndex];
for ( i = 0; i <= categoriesArray.length - 1; i++)
{ var categoriesObject = categoriesArray[i];
var categoriesText = categoriesObject[0];
var categoriesValue = categoriesObject[2];
ddlTrendCategory.options[i] = new Option(categoriesText,
categoriesValue);
}
var ddlTrendType = document.getElementById("ddlTrendType");
ddlTrendCategory.options[ddlTrendCategory.options.length] = new
Option("All Categories", 0);
When I post this back to the server, if i use
ddlTrendCategory.SelectedValue.ToString() it claims it evalutates to "". If i
use ddlTrendCategory.SelectedItem.Value.ToString() then it errors, with a
null reference error.

So, seemingly ASP.NET is not recognising that the drop down list has
contents. Is there a way round this, or is the whole approach I was asked to
do invalid and doomed to fail!

Help appreciated. Thanks in avance.
Nov 19 '05 #1
1 2142
you have to retrieve the value by yourself.
like:
request.form("mydropdown")
will contain the selected value of the dropdown.

if your dropdownlist is not populated from the server side, you can't use
the server side object model. from a server side point of view, the
dropdownlist is empty, so you can't select anything from this point of view.
"craig@amtdatatechnologies"
<cr**********************@discussions.microsoft.co m> wrote in message
news:4F**********************************@microsof t.com...
Hi,

I've been asked to create a page that dynamically populates the contents
of
related drop down lists using JavaScript, and then obviously posts things
back to the server.

For completeness, I re-produce example JavaScript below (this seemingly
works fine - but just to let you see what is going on)

e.g. var categoriesArray = TrendCategoriesHolder[intTrendIndex];
for ( i = 0; i <= categoriesArray.length - 1; i++)
{ var categoriesObject = categoriesArray[i];
var categoriesText = categoriesObject[0];
var categoriesValue = categoriesObject[2];
ddlTrendCategory.options[i] = new Option(categoriesText,
categoriesValue);
}
var ddlTrendType = document.getElementById("ddlTrendType");
ddlTrendCategory.options[ddlTrendCategory.options.length] = new
Option("All Categories", 0);
When I post this back to the server, if i use
ddlTrendCategory.SelectedValue.ToString() it claims it evalutates to "".
If i
use ddlTrendCategory.SelectedItem.Value.ToString() then it errors, with a
null reference error.

So, seemingly ASP.NET is not recognising that the drop down list has
contents. Is there a way round this, or is the whole approach I was asked
to
do invalid and doomed to fail!

Help appreciated. Thanks in avance.

Nov 19 '05 #2

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

Similar topics

4
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...
1
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...
3
by: Stephen Adam | last post by:
Hi there, I'm sure i'm missing something really simple here, all i want to do is get the value of the selected item in a list box. Even after much fiddling about last night I still could not get...
2
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...
3
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...
2
by: gk | last post by:
i want to have 2 dpendent drown box. one for country , and the other for city. if you change country in box1 , the city list will also change in box2.. How to do it in javascript ? can...
5
by: NickMc71 | last post by:
Hello, My page is dynamically generating a product listing for a drop down list based on our options. For example, one page might show this: <select name=stylekey> <option...
15
by: ajos | last post by:
Hello all, Im making a dependent drop down for my application for filtering purpose. I have populated the drop down from the database and retrieved in the html. <tr> <td valign="top"...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.