Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics 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 December 29th, 2003, 03:38 PM
Registered User
 
Join Date: Oct 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default select a value from ddl at page load

I would like a dropdown list to load with all values in a database table, which is no problem. But, I would then like it to display a selected text value from that list, depending on the value returned by a SQL query. As an example, say I was looking-up someone's personal data and there was a dropdown list that listed all the possible hair colors. If this person had been entered as having blonde hair, I want the dropdown list to display blonde at page load, but give the user the option to select another color if a change is needed. Is this possible?

KO
 
Old December 29th, 2003, 05:59 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Set the "SelectedValue" property on page load. This example uses a dataset to hold the SQL query:

ddlName.SelectedValue = dsDataSetName.Tables("tblName").Rows(0).Item("Item ToBeSelected")

Modify this according to your code.

J
 
Old December 29th, 2003, 06:02 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Add on to previous message:

Note that the value in the dropdown list will have to be equal to the database value...

J
 
Old December 29th, 2003, 07:02 PM
Registered User
 
Join Date: Oct 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, I want the value that is displayed to be one of the values already stored in the database table I am querying. I just don't necessarily want it to be the first value.

KO
 
Old December 29th, 2003, 07:26 PM
Registered User
 
Join Date: Oct 2003
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I guess the easiest way to say it is that, normally, the default text that is displayed at page load by a dropdown list is whatever is stored at index 0. I want to be able to select any item from the list to display as the default, so that my selection is the first thing the user sees when the page loads.

KO
 
Old December 29th, 2003, 09:00 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

How exactly are you using this? Are you using it as an update page?
If so, my suggestion should work for you. It is one of the methods that I use.

J





Similar Threads
Thread Thread Starter Forum Replies Last Post
how can selectedvalue of DDL make other DDL visibl hertendreef ASP.NET 2.0 Professional 4 May 20th, 2008 04:38 PM
... how to load a page without a trace ??? dk6607 ASP.NET 1.0 and 1.1 Professional 4 September 4th, 2007 09:10 AM
page could not be load on browser vivek123 ASP.NET 1.0 and 1.1 Professional 2 August 28th, 2006 05:01 AM
Page won't load data in IE rinventive PHP How-To 8 June 23rd, 2006 10:03 PM
page load() task vijayapteET Classic ASP Basics 1 October 3rd, 2005 10:19 PM





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