I read my dropdownlost data from one of my tables on database . I want to add an external value ( Select ) to my dropdownlist ..
This is my datasorource sql code
SELECT ID, Part, fxCarId
FROM tblParts
WHERE (fxCarId = @fxCarId)
UNION
SELECT TOP (1) 0 AS Expr2, 'Select' AS Expr1
FROM tblParts AS tblParts_1
How can I add this ‘ Select ‘ text into my dropdownlist ?
You were along the right lines, but your union requires that both statements have the same number of columns, you had 2 columns in the top part and only 2 on the bottom.
SQL-Server also doesn’t require that you select directly from a table, so rather than doing
SELECT TOP 1from a table, you can specify your values directly:What I tend to do to ensure “Select” is at the top of any drop down is add a SortOrder column, this way you can ensure “Select” is the default value at the top of the list, but the remainder of the drop down is in alphabetical order which is more logical for the user.