 |
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
|
|
|
|

September 15th, 2004, 08:51 AM
|
Authorized User
|
|
Join Date: Jul 2004
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

September 15th, 2004, 10:26 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
Can you post your code?
You will have to use a JOIN and send the city_names to the DDL.
|

September 15th, 2004, 10:35 AM
|
Authorized User
|
|
Join Date: Jul 2004
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

September 15th, 2004, 10:39 AM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
Is the ID of the city in the 'value' field of the DDL?
|

September 15th, 2004, 02:05 PM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
The dropdown list exposes a SelectedItem and SelectedValue property, so for the value, use SelectedValue, for the text use SelectedItem.Text.
Brian
|

September 15th, 2004, 02:15 PM
|
Authorized User
|
|
Join Date: Jul 2004
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

September 15th, 2004, 02:50 PM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
Try something like:
myDDL.DataTextField = "city_names"
myDDL.DataValueField = "city_id"
|

September 15th, 2004, 03:26 PM
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
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
|

September 16th, 2004, 07:11 AM
|
Authorized User
|
|
Join Date: Jul 2004
Posts: 71
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|
 |