No me ejecuta un EVENTO
Publicado por Homnas (5 intervenciones) el 18/11/2010 17:43:16
Buenas a todos!
Tengo un problema que me esta volviendo loco. Estoy creando una tabla en tiempo de ejcucion y a cada fila de la tabla le estoy agregando un checbox para poder modificar los datos de esa fila. Mi problema es el siguiente. Al hacer CheckedChanged en el checbox, el evento que tengo agregado a ese objeto, no se ejecuta. He probado de todo y pude conseguir que me ejecutara el evento solamente cuando hize la llamada dentro de Load pero sin que este dentro de ningun if y antes que cualquier llamada.
Hos adjunto la llamada a cargar la tabla y como crear la tabla:
LLAMADA:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
SiSS = vbDatabase.ConsSI
Inv= vbDatabase.ConsIn
busqueda = Request.QueryString("num")
CargarTabla(busqueda) ' ESTA ES LA LLAMADA A LA TABLA. ASI SI FUNCIONA
If Not Page.IsPostBack Then
CargarDrops()
If busqueda <> Nothing Then
If ComprobarTraslado() Is Nothing Then
busqueda = busqueda.Substring(0, 9)
'CargarTabla(busqueda) ' ESTA ES LA LLAMADA A LA TABLA. ASI NO FUNCIONA
EsModificar(busqueda)
Session.Add("nump", busqueda)
Else
EsTraslado()
End If
Else
EsNuevo()
End If
End If
If Page.IsPostBackEventControlRegistered And pedidobusqueda <> "" Then
CargarTabla(pedidobusqueda) 'ESTA ES LA LLAMADA A LA TABLA. ASI NO FUNCIONA
End If
End Sub
CREAR LA TABLA:
Protected Sub CargarTabla(ByVal numpedido)
Dim RadioBut As RadioButton
Try
Dim f As TableRow
Dim DarkColor As Boolean
'Borramos la tabla
Tabla.Rows.Clear()
'Cabecera de la Tabla
Dim cabecera As New TableRow
AddCell(cabecera, "***")
AddCell(cabecera, "***")
cabecera.CssClass = "TablaCabecera"
cabecera.Height = Unit.Pixel(20)
Tabla.Rows.Add(cabecera)
'Filas de la tabla
Dim sm As vbCom
For Each sm In vbCom.LoadPro(num)
f = New TableRow
Dim c As TableCell
RadioBut = New RadioButton
'Añadimos un evento relacionado con el Radio Button añadido
RadioBut.AutoPostBack = True
AddHandler RadioBut.CheckedChanged, AddressOf Click_Seleccionar
'Detecta el control Check y le da el nombre
RadioBut.SkinID = sm.***
RadioBut.GroupName = "Seleccion"
c = AddCell(f, "")
c.Controls.Add(RadioBut)
AddCell(f, sm.***)
AddCell(f, sm.***)
c.CssClass = "celda"
If DarkColor Then
f.CssClass = "TablaFilaOscura"
Else
f.CssClass = "TablaFilaClara"
End If
f.Height = Unit.Pixel(20)
Tabla.Rows.Add(f)
DarkColor = Not DarkColor
Next
Catch ex As System.Data.SqlClient.SqlException
MsgBox(ex.Message, , "Error de Base de Datos")
End Try
End Sub
Public Function AddCell(ByRef t As TableRow, ByVal texto As String) As TableCell
Dim c As New TableCell
c.Text = texto
t.Cells.Add(c)
AddCell = c
End Function
Muchas gracias por todo!!
Tengo un problema que me esta volviendo loco. Estoy creando una tabla en tiempo de ejcucion y a cada fila de la tabla le estoy agregando un checbox para poder modificar los datos de esa fila. Mi problema es el siguiente. Al hacer CheckedChanged en el checbox, el evento que tengo agregado a ese objeto, no se ejecuta. He probado de todo y pude conseguir que me ejecutara el evento solamente cuando hize la llamada dentro de Load pero sin que este dentro de ningun if y antes que cualquier llamada.
Hos adjunto la llamada a cargar la tabla y como crear la tabla:
LLAMADA:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
SiSS = vbDatabase.ConsSI
Inv= vbDatabase.ConsIn
busqueda = Request.QueryString("num")
CargarTabla(busqueda) ' ESTA ES LA LLAMADA A LA TABLA. ASI SI FUNCIONA
If Not Page.IsPostBack Then
CargarDrops()
If busqueda <> Nothing Then
If ComprobarTraslado() Is Nothing Then
busqueda = busqueda.Substring(0, 9)
'CargarTabla(busqueda) ' ESTA ES LA LLAMADA A LA TABLA. ASI NO FUNCIONA
EsModificar(busqueda)
Session.Add("nump", busqueda)
Else
EsTraslado()
End If
Else
EsNuevo()
End If
End If
If Page.IsPostBackEventControlRegistered And pedidobusqueda <> "" Then
CargarTabla(pedidobusqueda) 'ESTA ES LA LLAMADA A LA TABLA. ASI NO FUNCIONA
End If
End Sub
CREAR LA TABLA:
Protected Sub CargarTabla(ByVal numpedido)
Dim RadioBut As RadioButton
Try
Dim f As TableRow
Dim DarkColor As Boolean
'Borramos la tabla
Tabla.Rows.Clear()
'Cabecera de la Tabla
Dim cabecera As New TableRow
AddCell(cabecera, "***")
AddCell(cabecera, "***")
cabecera.CssClass = "TablaCabecera"
cabecera.Height = Unit.Pixel(20)
Tabla.Rows.Add(cabecera)
'Filas de la tabla
Dim sm As vbCom
For Each sm In vbCom.LoadPro(num)
f = New TableRow
Dim c As TableCell
RadioBut = New RadioButton
'Añadimos un evento relacionado con el Radio Button añadido
RadioBut.AutoPostBack = True
AddHandler RadioBut.CheckedChanged, AddressOf Click_Seleccionar
'Detecta el control Check y le da el nombre
RadioBut.SkinID = sm.***
RadioBut.GroupName = "Seleccion"
c = AddCell(f, "")
c.Controls.Add(RadioBut)
AddCell(f, sm.***)
AddCell(f, sm.***)
c.CssClass = "celda"
If DarkColor Then
f.CssClass = "TablaFilaOscura"
Else
f.CssClass = "TablaFilaClara"
End If
f.Height = Unit.Pixel(20)
Tabla.Rows.Add(f)
DarkColor = Not DarkColor
Next
Catch ex As System.Data.SqlClient.SqlException
MsgBox(ex.Message, , "Error de Base de Datos")
End Try
End Sub
Public Function AddCell(ByRef t As TableRow, ByVal texto As String) As TableCell
Dim c As New TableCell
c.Text = texto
t.Cells.Add(c)
AddCell = c
End Function
Muchas gracias por todo!!
Valora esta pregunta


0