1

I am creating a website which has 1 dropdownlist that bound to Northwind database, Customers table. This Drop downlist will list all the countries from the tables. I have tried to add "Japan" (which was not in the list) to this dropdownlist. It was added but it always appear at the top (or default value). My question is: Is it possible to add Japan and not make it appear at the top, so it will follow the alphabetical order?

This is my code:

<asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="True" 
            AutoPostBack="True" DataSourceID="SqlDataSource1" DataTextField="Country" 
            DataValueField="Country"><asp:ListItem Text ="Japan" />
        </asp:DropDownList>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString2 %>" 

            SelectCommand="SELECT Country FROM Customers GROUP BY Country ORDER BY Country">
        </asp:SqlDataSource>

1 Answer 1

2

You can try this way in your sql script.

SELECT Country
FROM
(
    SELECT Country 
    FROM Customers 
    GROUP BY Country 

    UNION ALL

    SELECT 'JAPAN'
) M
ORDER BY Country
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you so much, this is exactly what I have been looking for

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.