一、前台Aspx <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:DropDownList ID="cboNames" runat="server"> </asp:DropDownList> <br /> <asp:Button ID="btnSortDescending" runat="server" Text="Sort Descending" OnClick="btnSortNames_Click" /> <asp:Button ID="btnSortAscending" runat="server" Text="Sort Ascending" OnClick="btnSortAscending_Click" /> </div> </form> </body> </html> 二、后台CS using System; using System.Collections.Generic; using System.Linq; using System.Web.UI.WebControls; using System.Text.RegularExpressions; namespace WebApplication1 { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { List<string> names = new List<string>() { "Malcolm", "Suprotim", "John", "Tony", "Alex", "Jason" }; cboNames.DataSource = names; cboNames.DataBind(); } string s = "zhaojiweizhaozhangzhao"; string[] arr = s.Split(','); foreach (string item in arr) Response.Write(item + "<br/>"); Response.Write(arr.Length); } protected void btnSortNames_Click(object sender, EventArgs e) { cboNames.DataSource = cboNames.Items.Cast<ListItem>() .OrderByDescending(o => o.Text) .ToList(); cboNames.DataBind(); } protected void btnSortAscending_Click(object sender, EventArgs e) { cboNames.DataSource = cboNames.Items.Cast<ListItem>() .OrderBy(o => o.Text) .ToList(); cboNames.DataBind(); } } }