18/10/2008, 16:33
|
| | Fecha de Ingreso: septiembre-2005 Ubicación: Medellin
Mensajes: 215
Antigüedad: 19 años, 3 meses Puntos: 0 | |
Respuesta: Controles creados dinámicamente desaparecen con controles comunes de asp.net nada...unos Label, TxtBox y CheckBoxList.
Este es el código:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
TxtAño.Text = Año
TxtSem.Text = Sem
Dim dr As SqlDataReader
dr = drEnc()
If dr.Read Then
TxtCodEnc.Text = dr.GetValue(0)
TxtNomEnc.Text = dr.GetValue(1)
LblAñoSem.Text = TxtAño.Text & TxtSem.Text
End If
GenerarControles()
End If
End Sub
Private Sub GenerarControles()
Dim dr1 As SqlDataReader, dr2 As SqlDataReader, dr3 As SqlDataReader
Dim C1 As Integer, C2 As Integer, C3 As Integer, Pos As Integer
Panel1.Controls.Clear()
dr1 = drNomTema(Trim(TxtCodEnc.Text))
While dr1.Read
dr2 = drNomPReg(Trim(dr1.GetValue(0).ToString))
C1 += 1
Dim LblTema As New Label
LblTema.ID = "LblTema" & CStr(C1)
LblTema.Font.Name = "Arial"
LblTema.Font.Bold = True
LblTema.Text = dr1.GetValue(1).ToString
LblTema.Style("Position") = "Relative"
LblTema.Style("Top") = CStr(Pos) & "px"
LblTema.Style("Left") = "0px"
Panel1.Controls.Add(LblTema)
Pos += 25
While dr2.Read
dr3 = drNomCodPreg(Trim(dr2.GetValue(0).ToString))
C2 += 1
Dim LblPreg As New Label
LblPreg.ID = "LblPreg" & CStr(C2)
LblPreg.Font.Name = "Arial"
LblPreg.Font.Bold = True
LblPreg.Text = CStr(C2) & ". " & dr2.GetValue(1).ToString
LblPreg.Style("Position") = "Relative"
LblPreg.Style("Top") = CStr(Pos) & "px"
LblPreg.Style("Left") = "0px"
Panel1.Controls.Add(LblPreg)
If Not (dr2.GetValue(1).ToString = "Opinión") Then
Dim RblRes As New RadioButtonList
RblRes.ID = Trim(dr2.GetValue(0).ToString)
RblRes.Font.Name = "Arial"
RblRes.Style("Position") = "Relative"
RblRes.Style("Top") = CStr(Pos) & "px"
RblRes.Style("Left") = "0px"
RblRes.EnableViewState = True
While dr3.Read
C3 += 1
RblRes.Items.Add(dr3.GetValue(1).ToString)
Pos += 25
End While
Panel1.Controls.Add(RblRes)
RblRes = Nothing
Else
Dim TxtCom As New TextBox
TxtCom.ID = "TxtCom"
TxtCom.Font.Name = "Arial"
TxtCom.Style("Position") = "Relative"
TxtCom.Style("Top") = CStr(Pos) & "px"
TxtCom.Style("Left") = "0px"
Dim Largo As System.Web.UI.WebControls.Unit
Largo = 550
TxtCom.Width = Largo
Panel1.Controls.Add(TxtCom)
End If
LblPreg = Nothing
End While
LblTema = Nothing
End While
End Sub
__________________ JU4N35 |