tabla dinamica y controles en tiempo de ejecucion
Publicado por oskarh (1 intervención) el 29/07/2010 06:43:28
hola, soy nuevo en esto.. trato de hacer una tabla cuyo numero de filas depende de una consulta.. esa parte esta perfecta
el problema viene cuando hago un arreglo de controles, el tamaño de este arreglo es la misma cantidad de filas.
//inicializo 4 arreglos de controles
Dim per As Integer = q.duracion
Dim mylblper(per) As Label
Dim mytxtvalor(per) As Label
Dim mytxtcantidad(per) As Label
Dim mylbltotal(per) As Label
Dim j As Integer
For j = 0 To per - 1
mylblper(j) = lblmuestra
mytxtvalor(j) = lblmuestra
mytxtcantidad(j) = lblmuestra
mylbltotal(j) = lblmuestra
Next j
'AHORA CREO LOS LABELS Q' SON LOS TITULOS DE LA TABLA, ADEMAS DE LAS FILAS
'DEL CONTENIDO.
'LUEGO ADICIONO ELEMENTOS DE LOS ARREGLOS DE CONTROLES.
'DIBUJA EL CONTROL, LUEGO PASA AL SIGUIENTE BORRA EL CONTRO ANTERIOR Y DIBUJA
'UNO NUEVO.
'AL FINAL SOLO DIBUJA EL ULTIMO CONTROL
'SOLO OCURRE CON LOS ARREGLOS DE CONTROLES DE SERVIDOR
'LOS CONTROLES Q' CORREN SOBRE CLIENTE NO TIENEN PROBLEMA
Dim lblper As New Label
Dim lblvalor As New Label
Dim lblcantidad As New Label
Dim lbltotal As New Label
lblper.Text = "Periodo"
lblvalor.Text = "Valor Unitario"
lblcantidad.Text = "Cantidad"
lbltotal.Text = "Valor total"
Table2.Rows(0).Cells(0).Controls.Add(lblper)
Table2.Rows(0).Cells(1).Controls.Add(lblvalor)
Table2.Rows(0).Cells(2).Controls.Add(lblcantidad)
Table2.Rows(0).Cells(3).Controls.Add(lbltotal)
For i = 1 To per - 1
Dim r As New TableRow()
Dim c1 As New TableCell()
Dim c2 As New TableCell()
Dim c3 As New TableCell()
Dim c4 As New TableCell()
c1.Controls.Add(mylblper(i - 1))
c2.Controls.Add(mytxtvalor(i - 1))
c3.Controls.Add(mytxtcantidad(i - 1))
c4.Controls.Add(mylbltotal(i - 1))
c1.Controls.Add(New LiteralControl("row " & j.ToString() & ", cell " & i.ToString()))
c2.Controls.Add(New LiteralControl("row " & j.ToString() & ", cell " & i.ToString()))
c3.Controls.Add(New LiteralControl("row " & j.ToString() & ", cell " & i.ToString()))
c4.Controls.Add(New LiteralControl("row " & j.ToString() & ", cell " & i.ToString()))
r.Cells.Add(c1)
r.Cells.Add(c2)
r.Cells.Add(c3)
r.Cells.Add(c4)
Table2.Rows.Add(r)
Next i
¿CUAL ES EL ERROR?... AGRADEZCO DE ANTEMANO
el problema viene cuando hago un arreglo de controles, el tamaño de este arreglo es la misma cantidad de filas.
//inicializo 4 arreglos de controles
Dim per As Integer = q.duracion
Dim mylblper(per) As Label
Dim mytxtvalor(per) As Label
Dim mytxtcantidad(per) As Label
Dim mylbltotal(per) As Label
Dim j As Integer
For j = 0 To per - 1
mylblper(j) = lblmuestra
mytxtvalor(j) = lblmuestra
mytxtcantidad(j) = lblmuestra
mylbltotal(j) = lblmuestra
Next j
'AHORA CREO LOS LABELS Q' SON LOS TITULOS DE LA TABLA, ADEMAS DE LAS FILAS
'DEL CONTENIDO.
'LUEGO ADICIONO ELEMENTOS DE LOS ARREGLOS DE CONTROLES.
'DIBUJA EL CONTROL, LUEGO PASA AL SIGUIENTE BORRA EL CONTRO ANTERIOR Y DIBUJA
'UNO NUEVO.
'AL FINAL SOLO DIBUJA EL ULTIMO CONTROL
'SOLO OCURRE CON LOS ARREGLOS DE CONTROLES DE SERVIDOR
'LOS CONTROLES Q' CORREN SOBRE CLIENTE NO TIENEN PROBLEMA
Dim lblper As New Label
Dim lblvalor As New Label
Dim lblcantidad As New Label
Dim lbltotal As New Label
lblper.Text = "Periodo"
lblvalor.Text = "Valor Unitario"
lblcantidad.Text = "Cantidad"
lbltotal.Text = "Valor total"
Table2.Rows(0).Cells(0).Controls.Add(lblper)
Table2.Rows(0).Cells(1).Controls.Add(lblvalor)
Table2.Rows(0).Cells(2).Controls.Add(lblcantidad)
Table2.Rows(0).Cells(3).Controls.Add(lbltotal)
For i = 1 To per - 1
Dim r As New TableRow()
Dim c1 As New TableCell()
Dim c2 As New TableCell()
Dim c3 As New TableCell()
Dim c4 As New TableCell()
c1.Controls.Add(mylblper(i - 1))
c2.Controls.Add(mytxtvalor(i - 1))
c3.Controls.Add(mytxtcantidad(i - 1))
c4.Controls.Add(mylbltotal(i - 1))
c1.Controls.Add(New LiteralControl("row " & j.ToString() & ", cell " & i.ToString()))
c2.Controls.Add(New LiteralControl("row " & j.ToString() & ", cell " & i.ToString()))
c3.Controls.Add(New LiteralControl("row " & j.ToString() & ", cell " & i.ToString()))
c4.Controls.Add(New LiteralControl("row " & j.ToString() & ", cell " & i.ToString()))
r.Cells.Add(c1)
r.Cells.Add(c2)
r.Cells.Add(c3)
r.Cells.Add(c4)
Table2.Rows.Add(r)
Next i
¿CUAL ES EL ERROR?... AGRADEZCO DE ANTEMANO
Valora esta pregunta


0