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

unable to retreive the values from drop down

I'm not able to retrieve the values from a drop down in .cs file using ddl.selectedValue while I'm able to retrieve in Javascript using a hidden variable.
The problem in detail:
Neither This
string dateTemp = Convert.ToString(ddlYear.SelectedIndex) + "-" + Convert.ToString(ddlMonth.SelectedIndex) + "-" + Convert.ToString(ddlDay.SelectedIndex);
nor This
string dateTemp = Convert.ToString(ddlYear.SelectedValue) + "-" + Convert.ToString(ddlMonth.SelectedValue) + "-" + Convert.ToString(ddlDay.SelectedValue);
is able to fetch me the values into the string.

But I'm able to get the values into a string in the javascript below:
var givenDate = new Date(+Year.options[Year.selectedIndex].text,
Month.selectedIndex, Day.selectedIndex+1)
document.getElementById("hdnDate").value=givenDate

Please comment....
Jul 25 '07 #1
3 2279
dip_developer
648 Expert 512MB
I'm not able to retrieve the values from a drop down in .cs file using ddl.selectedValue while I'm able to retrieve in Javascript using a hidden variable.
The problem in detail:
Neither This
string dateTemp = Convert.ToString(ddlYear.SelectedIndex) + "-" + Convert.ToString(ddlMonth.SelectedIndex) + "-" + Convert.ToString(ddlDay.SelectedIndex);
nor This
string dateTemp = Convert.ToString(ddlYear.SelectedValue) + "-" + Convert.ToString(ddlMonth.SelectedValue) + "-" + Convert.ToString(ddlDay.SelectedValue);
is able to fetch me the values into the string.

But I'm able to get the values into a string in the javascript below:
var givenDate = new Date(+Year.options[Year.selectedIndex].text,
Month.selectedIndex, Day.selectedIndex+1)
document.getElementById("hdnDate").value=givenDate

Please comment....
do you think Convert.ToString(ddlYear.SelectedIndex) will produce the dropdownlist item??...Never....it will show you the index of the selected item.........

but nothing wrong with this ..............

string dateTemp = Convert.ToString(ddlYear.SelectedValue) + "-" + Convert.ToString(ddlMonth.SelectedValue) + "-" + Convert.ToString(ddlDay.SelectedValue);

it should produce the expected result.....
may be the fault is not here......
double check your code......
Jul 25 '07 #2
RoninZA
78
the ddl.SelectedValue will only return a value if your ddl.ValueMember property is set, otherwise ddl.SelectedValue will be null.

Try ddl.Text or cast ddl.SelectedItem to your object type, so if your ddl is populated with DateTime objects, access it like this: (DateTime)ddl.SelectedItem.
Jul 25 '07 #3
Thank you people for your comments.
The issue was that the variables inside the dropdown were local variables in the JS. i.e. runs only in the client side. Hence I was unable to retrieve the values. I have to go with bringing the values into a hidden variable rather than retriving from drop downs.
Jul 25 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Rob Wire | last post by:
For the code below, how could I add an item in the drop down lists for both company and location to be an "All" selection that would send to the stored proc. spRptAttachments a value of "%" so...
2
by: R-D-C | last post by:
Hi, got a drop-down list on a windows form in VS.NET2003. In the form load when NOT a postback, we add four values to the drop-down list. These appear in Internet Explorer. When you click...
2
by: macyp | last post by:
I have to pass values from one aspx page to another. The controls I have in the first page are: a textbox, 3 drop down lists, and 2 check boxes, and a submit button. It is a search page, and the...
19
by: nazgulero | last post by:
Hello all, I wonder if anybody can give me a hint about what I have to do to get this working: I am creating a drop down box using the script below. The result is two text fields; now I want...
6
by: John | last post by:
I have a drop down on my form and I need all the values in that drop down and pass to a stored procedure, how can I get the values of the drop down and pass them all to my stored procedure call?
2
by: Jim Gregg | last post by:
Hello all, I am faced with some logic that I am unsure how to handle. Imagine that I am running a WMI query and I am outputting the data into a dynamically created ASP table control. Here is my...
2
by: agarwalsrushti | last post by:
Hi, Ive made dynamic drop down boxes. On selection of value from first drop down box the values in second drop down are displayed. I ve made this two drop down in a separate file. I want to store...
1
by: bytenut | last post by:
I would like to display two field values in a combo after selecting from the list items... i.e. my drop-down shows two fields from a lookup, but when I select the item, only the first field value is...
3
by: phpmagesh | last post by:
Hi, I have a drop down in my page, what i will do with that drop down is i have a table in my database, which have values and this table will refer that ID and pick the name of that values and...
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...
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...
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
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
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.