Reputation: 27
The following code is a drop down box that displays Schools from a database, is there anyway to make these Schools display in alphabetical order?
<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>
</td>
Upvotes: 1
Views: 712
Reputation: 32760
Change your select command to:
SELECT [SchoolName] FROM [tbl_school] ORDER BY [SchoolName] ASC
Upvotes: 3