Foros del Web

Foros del Web (http://www.forosdelweb.com/)
-   ASPX (.net) (http://www.forosdelweb.com/f78/)
-   -   label y imagenbutton en columna de un datagrid (http://www.forosdelweb.com/f78/label-imagenbutton-columna-datagrid-386510/)

jhernanp 18/04/2006 11:00

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

lang.net 18/04/2006 13:16

Hola, tu cast deberia ser,
Line 67: lbdl = Ctype(dgi.Cells(11).Controls(1), Label)

Saludos,
Luis Alberto.

Irving_24 17/05/2006 15:33

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.


La zona horaria es GMT -6. Ahora son las 05:22.

Desarrollado por vBulletin® Versión 3.8.7
Derechos de Autor ©2000 - 2026, Jelsoft Enterprises Ltd.