none
populating a 2 listboxes from a database RRS feed

  • Question

  • 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

    Thursday, December 31, 2015 6:18 PM

Answers

  • LeyBoo,

    I don't see anything in your question that relates to customizing or programming of Microsoft Project, a project management application but that is the sole focus of this forum. I suggest you delete your post here and re-post to an appropriate forum. You could start here:

    https://social.technet.microsoft.com/Forums/en-US/home?category=usingforums

    John

    Thursday, December 31, 2015 6:38 PM