To order list items by text that is passed for VS2003

private void OrderListItems(System.Web.UI.WebControls.ListControl lc, string[] textValues) {

    ArrayList al = new ArrayList();

    foreach (System.Web.UI.WebControls.ListItem li in lc.Items) {

        al.Add(li);

    }

 

    lc.Items.Clear();

 

    foreach (string s in textValues) {

        foreach (System.Web.UI.WebControls.ListItem li in al) {

            if (li.Text == s) {

                lc.Items.Add(li);

            }

        }

    }

}

Comments are closed.