Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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


  #2 (permalink)  
Old September 15th, 2004, 10:26 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 1,111
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.

  #3 (permalink)  
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

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

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

  #5 (permalink)  
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
  #6 (permalink)  
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



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

Try something like:

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

  #8 (permalink)  
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
  #9 (permalink)  
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

 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 06:47 AM.


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