Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
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 September 15th, 2004, 08:51 AM
Authorized User
 
Join Date: Jul 2004
Location: St. John\'s, NL, Canada.
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
Default Drop Down List

Hello,

I have a drop down list (ddl) on a page that selects a city for a particularly user. The city selected comes from a different table (city) and the ID of that City is stored in the User Table. I can display the city no problems, my problem is how do I update the city, so that the ddl displays the city names, instead the City ID into the User table?

Thanks in Advance,
Mark


 
Old September 15th, 2004, 10:26 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Can you post your code?

You will have to use a JOIN and send the city_names to the DDL.

 
Old September 15th, 2004, 10:35 AM
Authorized User
 
Join Date: Jul 2004
Location: St. John\'s, NL, Canada.
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I know this and have this done...as my cities display in the ddl fine. The problem is that I want to insert the ID of the city from the city table into the City field of the user table.

Please help.

Mark

 
Old September 15th, 2004, 10:39 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Is the ID of the city in the 'value' field of the DDL?

 
Old September 15th, 2004, 02:05 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

The dropdown list exposes a SelectedItem and SelectedValue property, so for the value, use SelectedValue, for the text use SelectedItem.Text.

Brian
 
Old September 15th, 2004, 02:15 PM
Authorized User
 
Join Date: Jul 2004
Location: St. John\'s, NL, Canada.
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the repies guys. The thing is:
The value property is the list value...my ID is a autonumber from the City Table in the Database.
Please correct me if I am wrong!!
For ex:
 DDL Value Database ID Database TEXT
   1 1 New York
   2 5 St. Thomas
   3 6 St. John's
   4 7 Halifax
   5 10 Calgary
   6 11 Somewhere else

Any help is greatly appreciated,
Thanks,
Mark



 
Old September 15th, 2004, 02:50 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Try something like:

myDDL.DataTextField = "city_names"
myDDL.DataValueField = "city_id"

 
Old September 15th, 2004, 03:26 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

Do you need both sets of numbers? If so, you could append them together and use split to separate them. Of course, you have to programmably add each item to the dropdownlist that way.

Brian
 
Old September 16th, 2004, 07:11 AM
Authorized User
 
Join Date: Jul 2004
Location: St. John\'s, NL, Canada.
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
Default

No I do not need both Numbers. All I need is the value/number to be added to the User table in the City field and the actual name of the city show in the ddl for the user to see. For ex:
The Database user picks <Calgary> from the DDL, for the user JIM. the database adds the ID of Calgary (which is 23) to the city field in the user table. So In Jim's record the city field is 23.

Thanks,
Mark





Similar Threads
Thread Thread Starter Forum Replies Last Post
drop down list ashu_gupta75 Excel VBA 1 October 15th, 2007 05:52 PM
Drop down list carumuga Classic ASP Basics 1 February 6th, 2007 02:37 PM
drop down list values based on another drop down noor ASP.NET 1.0 and 1.1 Basics 3 July 5th, 2005 09:57 AM
Drop Down List mrideout BOOK: Beginning ASP.NET 1.0 6 March 18th, 2005 03:32 AM





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