Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 1.0
This is the forum to discuss the Wrox book Beginning ASP.NET 1.0 with C# by Chris Goode, John Kauffman, Christopher L. Miller, Neil Raybould, S. Srinivasa Sivakumar, Dave Sussman, Ollie Cornes, Rob Birdwell, Matt Butler, Gary Johnson, Ajoy Krishnamoorthy, Juan T. Llibre, Chris Ullman; ISBN: 9780764543708
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 1.0 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 16th, 2004, 11:44 PM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 245
Thanks: 0
Thanked 0 Times in 0 Posts
Default SelectedItem.Value vs. SelectedItem.Text

Basic question:

DropDownList1.SelectedItem.Value vs. DropDownList1.SelectedItem.Text

When do you use which one?

Can DropDownList1.SelectedItem.Text have both characters and numericals but DropDownList1.SelectedItem.Value is only for numericals?

Is the .Value one for CategoryIDs and the .Text for Text values?

What the exact use for this?

 
Old June 17th, 2004, 07:07 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Both of these parameters accept strings. A string can take any letter or number, or other ASCII characters. You use whichever one you need. For example, what I'll do is show a list of options, and for the value I'll store the unique ID number in it, and then when the user selects an option, get the ID number from the value, and query the database for those results.

You use whatever one you want to, for your situation. Whatever action you are performing, do you need the text value or the ID? ID's are typically more precise if you are querying a database, because they are unique, where text values can duplicate. It depends on your need.

Remember too that there is another shortcut to the value in DropDownList1.SelectedValue.

Hope this helps,

Brian
 
Old June 17th, 2004, 07:23 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 245
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks






Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert Text(Sql Server Text Field) to Image(JPG) srinivas72 ADO.NET 2 February 13th, 2009 06:31 PM
Listview SelectedItem Apocolypse2005 Visual Basic 2005 Basics 1 October 28th, 2007 01:08 PM
Can't EASILY set cbo.selecteditem using VALUE Ron Howerton Visual Basic 2005 Basics 5 December 14th, 2006 04:52 PM
Listbox selecteditem to string Alcapone C# 2 October 28th, 2004 02:18 AM
SelectedItem in ComboBox miguel.ossa C# 1 September 28th, 2004 06:50 PM





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