Ver Mensaje Individual
  #1 (permalink)  
Antiguo 28/09/2010, 11:25
nyjo
 
Fecha de Ingreso: septiembre-2010
Mensajes: 12
Antigüedad: 13 años, 7 meses
Puntos: 0
Problemas con controles dinamicos

Hola a todos....
Estoy buscando en internet pero no encuentro una solucion mi problema es este.

estoy creando texbox dinamicos, primero en un textbox normal ingreso un numero y al hacer click en un boton me crea el numero de textbox indicado en el anterior, eso lo hace normalmente, pero cuando intento recuperar la informacion de los textbox dinamicos al usar findcontrol me devuelve nulo, inclusive utilize un update panel para que no se perdiesen los controles en el postback pero nada.
Mi codigo es este:
Cita:
'Para crear los textbox:

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim tabla As New Table
' numero total de filas
Dim rowCnt As Integer
' fila actual
Dim rowCtr As Integer
' celda actual
Dim cellCnt As Integer
'rowCnt = CInt(TextBox1.Text)
rowCnt = CInt(valor)
cellCnt = 1
For rowCtr = 1 To rowCnt
Dim tRow As New TableRow()
Dim tCell As New TableCell()
Dim txt As New TextBox 'control a crear
Dim txt2 As New TextBox 'control a crear
txt.ID = "txtRubro" + CStr(rowCtr)
txt.Font.Name = "Cambria"
txt.Font.Size = 10
txt.Width = 191
tCell.Controls.Add(txt)
txt2.ID = "txtArea" + CStr(rowCtr)
txt2.Font.Name = "Cambria"
txt2.Font.Size = 10
txt2.Width = 78
txt2.Style.Value = "text-align : center"
txt2.Attributes.Add("onKeyPress", "return AcceptNum(event)")
txt2.Attributes.Add("onKeyPress", "return control(event, this)")
txt2.Attributes.Add("onBlur", "return valores(event, this)")
tCell.Controls.Add(txt2)
tRow.Cells.Add(tCell)
tabla.Rows.Add(tRow)
Next rowCtr
Me.Espacio.Controls.Add(tabla)
End Sub

'Para recuperar el valor de uno de los textbox dinamicos:

Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim txt As String = "txtRubro" + (1).ToString()
Dim txtControl As TextBox = TryCast(Espacio.FindControl(txt), TextBox)
lblValor.Text = txtControl.Text
End Sub
Les agracezco mucho su ayuda de antemano...