Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / February 2008

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bart - 01 Feb 2008 23:14 GMT
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
bruce barker - 01 Feb 2008 23:44 GMT
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)

> Hi,
>
[quoted text clipped - 15 lines]
> Thanks
> Bart
Bart - 02 Feb 2008 10:49 GMT
Thanks, but i get an error when executing it in Studio Management:
Incorrect syntax near the keyword 'case'.

> i'd use an order by clause.
>
[quoted text clipped - 28 lines]
>> Thanks
>> Bart
bruce barker - 03 Feb 2008 05:23 GMT
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, but i get an error when executing it in Studio Management:
> Incorrect syntax near the keyword 'case'.
[quoted text clipped - 31 lines]
>>> Thanks
>>> Bart
Bart - 03 Feb 2008 11:30 GMT
Thanks, it works now

> simple typo (its just case ... end), you should read the docs:
>
[quoted text clipped - 40 lines]
>>>> Thanks
>>>> Bart

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.