Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
VS.NET 2002/2003 Discussions about the Visual Studio.NET programming environment, the 2002 (1.0) and 2003 (1.1). ** Please don't post code questions here ** For issues specific to a particular language in .NET, please see the other forum categories.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VS.NET 2002/2003 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 10th, 2004, 06:04 AM
Authorized User
 
Join Date: May 2004
Location: , , .
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default DropDownList

Is there any way to capture the text which the user has selected from a dropdown field box? i.e.

dropdownlist.selecteditem.text (something like this)

 
Old June 10th, 2004, 07:28 AM
Friend of Wrox
Points: 2,473, Level: 20
Points: 2,473, Level: 20 Points: 2,473, Level: 20 Points: 2,473, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2004
Location: India
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

I think the answer is inur question if i am right..

dropdownlist.selecteditem.text

Om Prakash
 
Old June 10th, 2004, 10:13 AM
Authorized User
 
Join Date: May 2004
Location: , , .
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
Default

its dlist.selectedvalue

 
Old June 10th, 2004, 11:25 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hello,

Do you want the text or the underlying value? For text, it's dropdownlist.selecteditem.text, and for the underlying value, it's dropdownlist.selectedvalue, as shown in the above posts.

Brian
 
Old June 14th, 2004, 11:28 PM
Authorized User
 
Join Date: May 2004
Location: , , .
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

Thanks for the replies.

I want the the text to be supplied to me. I will match this text with the value in my database and then want to create a session variable storing this value accordingly. I am using the following code.

Code:
if portalList.SelectedItem.text = objDataReader.GetString(0) then
            Session("course_id") = objDataReader.GetInt32(1).toString()
        end if

However, this is not working as when i response.write my course_id variable then I always get "1" as my output value where I am changing my dropdown list values so I think something is wrong, I don't know what thought but my SQL statement is fine.

Any suggestions here.

 
Old June 15th, 2004, 03:12 AM
Authorized User
 
Join Date: May 2004
Location: , , .
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Solved it.

Didnt use page.ispostback on page_load

also autopostback property should be set to true in the <asp:dropdownlist

Hope this helps someone else with similar probs :)





Similar Threads
Thread Thread Starter Forum Replies Last Post
dropdownlist sumith ASP.NET 1.0 and 1.1 Professional 1 February 23rd, 2007 09:11 AM
DropdownList Venkatesan ASP.NET 1.0 and 1.1 Basics 1 December 11th, 2006 11:03 AM
how to get value from dropdownlist vandat ASP.NET 1.0 and 1.1 Basics 3 November 28th, 2005 12:47 AM
dropdownlist msrnivas .NET Web Services 0 March 4th, 2004 11:01 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.