How to sort DropDownList items by text in dropdownlist sort by text
The following c# example code demonstrate us how can we sort a DropDownList items by its item's text. Each ListItem object have a Text property and a Value property. We can sort DropDownList items by based on both 'Text' property value or 'Value' property value.

DropDownList class does not support direct sorting of its items. To sort a DropDownList we need to write few lines of code. First we initialize a Generic List with data type ListItem. Then we populate the Generic List from DropDownList items. After populating the Generic List with items, we can sort those items by calling OrderBy() method. We sort the Generic List items based on ListItem object's Text property value. In this example code we sorted DropDownList items on ascending order.

Finally we need to remove all items from DropDownList and populate it again with Generic List sorted items. This is the process we applied to sort DropDownList items based on item's text.

<%@ Page Language="C#" AutoEventWireup="true"%>    
<!DOCTYPE html>
<script runat="server">  
    protected void Page_Load(object sender, EventArgs e)  
            //this line create a generic list data type ListItem
            List<ListItem> list = new List<ListItem>();

            foreach (ListItem li in DropDownList1.Items)
                //add ListItem to generic list

            //sort list items by item text alphabetically/ascending
            List<ListItem> sorted = list.OrderBy(b => b.Text).ToList();

            //empty dropdownlist
            //repopulate dropdownlist with sorted items.
            foreach (ListItem li in sorted)
<html xmlns="">        
<head id="Head1" runat="server">        
    <title> dropdownlist sort by text</title>  
    <form id="form1" runat="server">        
        <h2 style="color:MidnightBlue; font-style:italic;">        
   example - dropdownlist sort by text
        <hr width="550" align="left" color="Gainsboro" />        
        <br /><br />  
            Font-Names="Comic Sans MS"
            <asp:ListItem Text="Turkey Vulture" Value="1"></asp:ListItem>
            <asp:ListItem Text="Eurasian Hobby" Value="2"></asp:ListItem>
            <asp:ListItem Text="Northern Crested Caracara" Value="3"></asp:ListItem>
            <asp:ListItem Text="American Kestrel" Value="4"></asp:ListItem>
            <asp:ListItem Text="Peregrine Falcon" Value="5"></asp:ListItem>
More examples