Salve a tutti, ho la seguente sub che si occupa di crearmi dinamicamente una tabella con delle textbox runat=server:
Ovunque io lanci la sub, sia in init, che in preload o dove altro, se poi tento tramite un button ad esempio (o in qualsiasi altro modo) di riferirmi ad una textbox così creata (es: "IP_3.text") mi dice che il controllo non esiste. Sapete dirmi dove sbaglio?codice:Private Sub CreateDynamicTable() Dim tblRows As Integer = 64 Dim tblCols As Integer = 8 Dim intRQS As Integer = 1 Dim startRow As Integer = ((64 * intRQS) - 64) Dim tbl As Table = New Table() tbl.ID = "tblMain" tbl.Attributes.Add("runat", "server") PlaceHolder1.Controls.Add(tbl) For i As Integer = startRow To (startRow + tblRows - 1) Dim tr As TableRow = New TableRow() For j As Integer = 0 To tblCols - 1 Dim tc As TableCell = New TableCell() Dim txtBox As TextBox = New TextBox() If (j Mod 2) = 0 Then txtBox.Width = "80" txtBox.Text = "10.14.1." & (i + (64 * (j / 2))) txtBox.ID = "IP_" & (i + (64 * (j / 2))) txtBox.BackColor = Drawing.Color.AntiqueWhite Else txtBox.Width = "150" txtBox.Text = "Desc. no. " & (i + (64 * (j / 2))) txtBox.ID = "DS_" & (i + (64 * ((j - 1) / 2))) txtBox.BackColor = Drawing.Color.Beige End If txtBox.Attributes.Add("runat", "server") txtBox.AutoPostBack = False txtBox.ReadOnly = True tc.Controls.Add(txtBox) tr.Cells.Add(tc) Next j tbl.Rows.Add(tr) Next i tbl.BorderStyle = BorderStyle.Solid tbl.BorderColor = Drawing.Color.Black tbl.BorderWidth = "1" End Sub
FYI, il placeholder1 sta in un form creato a mano (formQ) che é runat=server.
Per farvi capire un po' meglio l'output che da il codice vi mostro uno spezzone della tabella (tutta era troppo grande).
http://img228.imageshack.us/img228/6780/tblip.jpg
Vi ringrazio per un aiuto.
Luca

Rispondi quotando