Author: Icarus1_uk | Posted on: 8/17/2009 9:50:51 AM | Views : 350

Have wrriten the following code to remove selected items from a listbox. However keep getting an Index out of range error and can't figure out why.
Sub remProd()

        Dim productsLbx As ListBox = dvSales.FindControl("lbxProducts")

        Dim count As Integer = productsLbx.Items.Count
        For i As Integer = 0 To count - 1
            If productsLbx.Items.Item(i).Selected Then   'Error occurs here
                productsLbx.Items.RemoveAt(i)
                i -= 1
                count -= 1
     ...

Go to the complete details ...