I have 2 listboxes where I populate from a database.
I want to show items that are not being used on left side and items being used on the right side.
I have this code already where it does work but it does throw an error saying " Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index"
If Not Request.QueryString("ID") Is Nothing Then
' lstPages.ClearSelection()
lstPages.DataSource = PageNames
lstPages.DataTextField = "PageName"
lstPages.DataValueField = "PageID"
lstPages.DataBind()
Dim lstItem As String
'Dim rowItems As ListItem
SelectedPgs = GetBanned.getCMSPagesByVialsID(Request.QueryString("ID"))
Try
Dim i As Integer
For i = 0 To lstPages.Items.Count - 1 Step i + 1
lstItem = lstPages.Items.Item(i).Value
For j = 0 To SelectedPgs.Rows.Count - 1
If lstItem = SelectedPgs.Rows(j).Item("PageID") Then
' lstPages.Items.Item(i).Selected = True
lstPages0.Items.Add(lstPages.Items.Item(i))
lstPages.Items.Remove(lstPages.Items.Item(i))
'i = SelectedPgs.Rows.Count - 2
'i = -1
End If
Next
Next
Catch ex As Exception
Finally
End Try
any help would be appreciated
D