how to put a particular value on top of dropdownlist connected to a sql table?

  • Thread starter Thread starter Bart
  • Start date Start date
B

Bart

Hi,

i have a dropdownlist connected to a sqldatasource like this:

<asp:DropDownList ID="DropDownList1" runat="server"
DataSourceID="SqlDataSource1" DataTextField="Name" DataValueField="Name">
</asp:DropDownList>


What i want is to put a particular value on the top of the dd. I can't use
ORDER BY.

e.g. the table which feeds the dd contains this:
R
D
A

how to put value D on top of the dd?
Thanks
Bart
 
i'd use an order by clause.

select name
from mytable
order by case
when name = 'D' then ''
else name
end case

-- bruce (sqlwork.com)
 
Thanks, but i get an error when executing it in Studio Management:
Incorrect syntax near the keyword 'case'.
 
simple typo (its just case ... end), you should read the docs:

select name
from mytable
order by case
when name = 'D' then ''
else name
end
 
Thanks, it works now

bruce barker said:
simple typo (its just case ... end), you should read the docs:

select name
from mytable
order by case
when name = 'D' then ''
else name
end
 
Back
Top