Results 1 to 3 of 3

Thread: [02/03] looping through checkboxes in a panel(s)

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2001
    Location
    Austin
    Posts
    397

    [02/03] looping through checkboxes in a panel(s)

    My usercontrol is going to have several panel controls on it. Within each panel there will be a checkboxlist and possibly a textbox. Depending on the value passed to the usercontrol a particular panel will be visible and the other panels won't be visible.

    So, without writing a massive amount of IF statements how can I capture the selected items in the checkboxlist of the visible panel?

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2001
    Location
    Austin
    Posts
    397

    Re: [02/03] looping through checkboxes in a panel(s)

    is there a more streamlined way of doing this?

    hManualTokens is a hashtable

    Code:
            Dim i As Integer
    
            For Each ctrl As Control In Page.Controls
    
                If TypeOf ctrl Is Panel Then
    
                    If ctrl.Visible = True Then
    
                        Dim iControlNumber As Integer = Right(ctrl.ID, 3)
                        If iControlNumber = "132" Then
    
                            For i = 0 To cb132.Items.Count - 1
                                If cb132.Items(i).Selected Then
    
                                    hManualTokens.Add(cb132.Items(i).Value, "X")
    
                                Else
    
                                    hManualTokens.Add(cb132.Items(i).Value, "_")
    
                                End If
                            Next i
    
                        ElseIf iControlNumber = "142" Then
    
                            For i = 0 To cb142.Items.Count - 1
                                If cb142.Items(i).Selected Then
    
                                    hManualTokens.Add(cb142.Items(i).Value, "X")
    
                                Else
    
                                    hManualTokens.Add(cb142.Items(i).Value, "_")
    
                                End If
                            Next i
    
                        End If
    
                    End If
                End If
    
            Next

  3. #3
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497

    Re: [02/03] looping through checkboxes in a panel(s)

    Don't the lists have a .SelectedItems array?
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width