Link to home
Start Free TrialLog in
Avatar of DowntownIT
DowntownITFlag for United States of America

asked on

List box help

I have an accordion where I am creating each pane dynamically through code. I am then dynamically creating and adding a list box and list items to each of the panes. What I can’t figure out, is how to capture the selected value and text of any given list box. I also need to be able that if the user selects a item from the list box in any of the panes that all other selected list box items of the other panes are cleared.

Thanks for the help!
Public Sub BuildAccordion()

     
        Dim dt As DataTable = ListData1.DefaultView.ToTable("MyPanes", True, New [String]() {"Screen_no", "Screen_desc"})

        For Each row As DataRow In dt.Rows

            Dim myStrExpr As String
            myStrExpr = "screen_no = " & row("Screen_no").ToString
            Dim lbScreen As New ListBox

            For Each row1 As DataRow In ListData1.Select(myStrExpr)
                lbScreen.Items.Add(New ListItem(row1("Floor/Location/Position").ToString, "Seat_no"))
            Next

            CreateAccPane(row("Screen_desc").ToString, row("Screen_desc").ToString, lbScreen)
        Next
    End Sub

    Public Sub CreateAccPane(ByVal PaneID As String, ByVal PaneHeader As String, ByVal PaneContent As ListBox)
        Dim panel1 As AccordionPane = New AccordionPane
        panel1.ID = PaneID
        panel1.HeaderContainer.Controls.Add(New LiteralControl(PaneHeader))

        panel1.ContentContainer.Controls.Add(PaneContent)

        AccPositions.Panes.Add(panel1)

    End Sub

Open in new window

Avatar of Krummelz
Krummelz
Flag of South Africa image

Dynamic controls are a complicated matter.
This article on 4guysfromrolla.com might provide you with some insight - http://www.4guysfromrolla.com/articles/092904-1.aspx.

I would try to avoid using dynamic controls if I were you. They can quickly turn into a headache.
Avatar of DowntownIT

ASKER

I understand where you are coming from and perfer not to do it. As the page stands now, I am using only one list box but it contains a couple hundred items. I figured that I could break that list box into a few list boxes by a common grouping of the items. The problem is that the common grouping changes so in one run, I could have 4 groups and in the next I could have 5 groups. Open to suggestions for another path.

Thanks,
ASKER CERTIFIED SOLUTION
Avatar of Krummelz
Krummelz
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Didn't think of that, that will be the route I will go.

Thanks for the suggestion!
You're welcome :) Glad I could help!