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

ASP.NET

Avatar of undefined
Last Comment
Krummelz
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
DowntownIT
Flag of United States of America image

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

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of DowntownIT
DowntownIT
Flag of United States of America image

ASKER

Didn't think of that, that will be the route I will go.

Thanks for the suggestion!
Avatar of Krummelz
Krummelz
Flag of South Africa image

You're welcome :) Glad I could help!
ASP.NET
ASP.NET

The successor to Active Server Pages, ASP.NET websites utilize the .NET framework to produce dynamic, data and content-driven web applications and services. ASP.NET code can be written using any .NET supported language. As of 2009, ASP.NET can also apply the Model-View-Controller (MVC) pattern to web applications

128K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo