1

下面的代码是一个显示数据库中学校的下拉框,有没有办法让这些学校按字母顺序显示?

<td align="right" style="text-align: right; width: 170px;">
    <asp:Label ID="School_lbl" runat="server" AssociatedControlID="School" 
        Text="School:"></asp:Label>
</td>
<td style="width: 206px">
    <asp:DropDownList ID="School" runat="server" DataSourceID="School_DS" 
        DataTextField="SchoolName" AppendDataBoundItems="True"
        DataValueField="SchoolName" Font-Names="verdana" Width="185px" 
        AutoPostBack="True"
        OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">

        <asp:ListItem Selected="True">-- Select --</asp:ListItem>
    </asp:DropDownList>
    <asp:AccessDataSource ID="School_DS" runat="server" 
        DataFile="~/App_Data/MockCourt_db.mdb"
        SelectCommand="SELECT [SchoolName] FROM [tbl_school]">
    </asp:AccessDataSource>
    &nbsp;&nbsp;
</td>
4

1 回答 1

3

将您的选择命令更改为:

SELECT [SchoolName] FROM [tbl_school] ORDER BY [SchoolName] ASC
于 2012-07-17T14:03:58.437 回答