' This routine is used to sort a given list object Public Shared Sub SortList(ByRef oLst As System.Web.UI.WebControls.ListControl, Optional ByVal bDesc As Boolean = False) ' Variables Dim aLst As New ArrayList() Dim aVal As New ArrayList() Dim nC%, nS% ' Assign Value nS = IIf(bDesc, -1, 1) ' Load Items into List For nC = 0 To oLst.Items.Count - 1 aLst.Add(oLst.Items(nC).Text) Next ' Sort List aLst.Sort() ' Load Values for Items For nC = 0 To aLst.Count - 1 aVal.Add(oLst.Items.FindByText(aLst(nC)).Value) Next ' Clear List oLst.Items.Clear() ' Reload Values If nS > 0 Then For nC = 0 To aLst.Count - 1 Step nS oLst.Items.Add(New System.Web.UI.WebControls.ListItem(aLst(nC), aVal(nC))) Next Else For nC = aLst.Count - 1 To 0 Step nS oLst.Items.Add(New System.Web.UI.WebControls.ListItem(aLst(nC), aVal(nC))) Next End If ' Free Memory aLst.Clear() aVal.Clear() aLst = Nothing aVal = Nothing End Sub