drop down list

Hi

I have a drop down list which gets populated from database but I want to add the default value as

--Select-

[129 byte] By [Paarul] at [2007-12-29]
# 1

Here's a trick you can use. Use a Union query to append your default to your database results, like so:

SELECT
0
as EmployeeID,
'-- Select An Employee --' as EmployeeName

UNION

SELECT
EmployeeID,
FirstName + ' ' + LastName as EmployeeName
FROM
employees

FrankCarr at 2007-9-4 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 2

Hi Frank

I tried it but I think I am not putting the qoutes properly.

SqlCommand("select '"&--Choose One--&"'" as typeName union select typeName from attributeType")

Paarul at 2007-9-4 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 3

Your string should look like this:

"select '--Choose One--' as typeName union select typeName from attributeType"

Remember to check for the default value before saving your information. You don't want to save "Choose One" to your database.

FrankCarr at 2007-9-4 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 4

Thanks Frank!!!

I tried t his also, creating a view on the table and than selecting the data from view.It works fine but I don't think its a good method.

Paarul at 2007-9-4 > top of Msdn Tech,Visual Basic,Visual Basic General...