Retroceder   Foros del Web > Programación para sitios web > .NET > web forms

Respuesta
 
Herramientas Desplegado
Antiguo 18-abr-2006, 11:00   #1 (permalink)
jhernanp ha deshabilitado el karma
 
Fecha de Ingreso: octubre-2004
Mensajes: 67
Pregunta label y imagenbutton en columna de un datagrid

quiero hacer lo siguiente en una columna de un datagrid colocar un label i una imagen los cuales los asigno por codigo de acuerdo a unos calculos que realizo

los asigno de la siguiente forma
Dim btnimg As ImageButton
Dim ldd As Label

ldd = dgi.Cells(24).Controls(1)
btnimg = dgi.Cells(24).Controls(2)

al hacer esto me saca el siguiente error

Specified cast is not valid.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Specified cast is not valid.

Source Error:


Line 67: lbdl = dgi.Cells(11).Controls(1)
Line 68: ldd = dgi.Cells(24).Controls(1)
Line 69: btnimg = dgi.Cells(24).Controls(0)
Line 70: fecha = lbf.Text
Line 71: ahora = LBfecha.Text
jhernanp está desconectado   Responder Citando
Antiguo 18-abr-2006, 13:16   #2 (permalink)
lang.net ha deshabilitado el karma
 
Fecha de Ingreso: diciembre-2004
Mensajes: 130
Hola, tu cast deberia ser,
Line 67: lbdl = Ctype(dgi.Cells(11).Controls(1), Label)

Saludos,
Luis Alberto.
__________________
langdotnet
lang.net está desconectado   Responder Citando
Antiguo 17-may-2006, 15:33   #3 (permalink)
Irving_24 ha deshabilitado el karma
 
Fecha de Ingreso: mayo-2006
Mensajes: 53
Specified cast is not valid.

Hola a Todos

Estoy haciendo una aplicación en donde estoy metiendo en un DataGrid el editCommand, cancelCommand y UpdateCommand, este es mi codigo:

Public Sub editarSeccion(ByVal s As Object, ByVal e As DataGridCommandEventArgs)
lst_sec.EditItemIndex = e.Item.ItemIndex
dame_secciones_inm()
End Sub
Public Sub cancelarEdicion(ByVal s As Object, ByVal e As DataGridCommandEventArgs)
lst_sec.EditItemIndex = -1
dame_secciones_inm()
End Sub
Public Sub actualizarSeccion(ByVal s As Object, ByVal e As DataGridCommandEventArgs)

Dim nombreSeccion As TextBox
nombreSeccion = CType(e.Item.Cells(1).Controls(0), TextBox)

'Actualiza a Base de Datos

cmd = New SqlClient.SqlCommand("UPDATE Seccion_Inmuebles SET Sec_Descripcion = @desc_sec WHERE IdSec = @Id_sec")
cmd.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Id_sec", System.Data.SqlDbType.Int, 4))
cmd.Parameters.Add(New System.Data.SqlClient.SqlParameter("@desc_sec", System.Data.SqlDbType.VarChar, 50))
cmd.Parameters("@Id_sec").Value = lst_sec.DataKeys.Item(e.Item.ItemIndex)
cmd.Parameters("@Id_sec").Value = nombreSeccion.Text
con.Open()
cmd.ExecuteNonQuery()
con.Close()

lst_sec.EditItemIndex = -1
dame_secciones_inm()

End Sub

Cuando Quiero actualizar me manda el siguiente error:


Specified cast is not valid.

Espero me puedan ayudar.
Irving_24 está desconectado   Responder Citando
Respuesta
No hay votos aún.


Herramientas
Desplegado

Normas de Publicación
No puedes crear nuevos temas
No puedes responder temas
No puedes subir archivos adjuntos
No puedes editar tus mensajes

BB code is Activado
Caritas están Activado
[IMG] está Activado
Código HTML está Desactivado


La Zona horaria es GMT -6. Ahora son las 00:05.


Message Board Statistics

LinkBacks Enabled by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93