Bonjour a tout le monde

Dans mon petit projet , je crées des (label, DropDownList) dynamiquement, a l'aide du code suivant
A savoir que dans ma page ASPx il y a un ContentPlaceHolder qui se nome ContentPlaceHolder1

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
 Dim DsDevicesPrinters As DataSet = New DataSet
 
                  Dim content As ContentPlaceHolder = DirectCast(Page.Master.FindControl("ContentPlaceHolder1"), ContentPlaceHolder)
 
                  Dim MyHtmlTable = New HtmlTable()
                  MyHtmlTable = DirectCast(content.FindControl("MyTableau"), HtmlTable)
 
for i=0 to UnNombre
 
  i += 1
 
                        Dim MaLigne = New HtmlTableRow()
                        MyHtmlTable.Rows.Add(MaLigne)
 
                        Dim cell = New HtmlTableCell()
                        cell.BgColor = "#2C84F7"
                        cell.Height = 120
                        cell.Width = "10%"
 
                        Dim NewLabel As Label
                        NewLabel = New Label
                        NewLabel.Width = 150
                        NewLabel.ID = "LabelLocation" & i
                        NewLabel.Text = DrDevicePrinters("MATWEB_LocalisationGeographique")
                        cell.Controls.Add(NewLabel)
                        MaLigne.Cells.Add(cell)
 
                        cell = New HtmlTableCell()
                        cell.BgColor = "#006699"
                        cell.Width = "10%"
                        NewLabel = New Label
                        NewLabel.Width = 80
                        NewLabel.ID = "LabelEmplacement" & i
                        NewLabel.Text = DrDevicePrinters("MATWEB_Emplacement")
                        cell.Controls.Add(NewLabel)
                        MaLigne.Cells.Add(cell)
 
Next
Jusque là pas de problème sa fonctionne plutôt bien

Je souhaiterais maintenant retrouver les Label , Ddl et autre contrôles créer avec la procédure ci-dessus. Mais là je nage un peut ( beaucoup peut être ), malgré des essais infructueux du genre:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  Dim allTextBoxValues As String = ""
                 Dim c As Control
            Dim childc As Control
            Dim childcc As Control
            For Each c In Page.Controls
                   For Each childc In c.Controls
                        For Each childcc In c.Controls
                              If TypeOf childcc Is Label Then
                                    allTextBoxValues &= CType(childcc, Label).ID & ","
                              End If
                        Next
                  Next
           Next
 
            Label2.Text = allTextBoxValues
Une suggestion peut être