Ver Mensaje Individual
  #1 (permalink)  
Antiguo 05/06/2013, 09:36
Avatar de aid_val
aid_val
 
Fecha de Ingreso: mayo-2013
Ubicación: Guanajuato
Mensajes: 302
Antigüedad: 11 años
Puntos: 5
Pregunta Error al pintar celdas en GridView

HOla a todos, hoy se me ha presentado un problema.
Quiero pintar mis celdas de color rojo cuando la cantidad faltante sea negativa, ya que eso me indica que es un excedente. pero cuando quiero cargar la pagina me manda error

este es mi code behind

Protected Sub gv_cantidades_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles gv_cantidades.DataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim cantidad As Single
cantidad = DataBinder.Eval(e.Row.DataItem, "cantidad_faltante")
If cantidad <= 5 Then
e.Row.BackColor = System.Drawing.Color.Red
e.Row.Font.Bold = True
End If
End If
End Sub

este es el error que me manda

No se puede convertir un objeto de tipo 'System.EventArgs' al tipo 'System.Web.UI.WebControls.GridViewRowEventArgs'.

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: No se puede convertir un objeto de tipo 'System.EventArgs' al tipo 'System.Web.UI.WebControls.GridViewRowEventArgs'.

Source Error:


[No relevant source lines]

Source File: C:\Users\Propietario\AppData\Local\Temp\Temporary ASP.NET Files\sipro\421e3836\3ed8522\App_Web_qn0tr4q0.0.vb Line: 0

Stack Trace:


[InvalidCastException: No se puede convertir un objeto de tipo 'System.EventArgs' al tipo 'System.Web.UI.WebControls.GridViewRowEventArgs'.]
formas_cargar_prefiniquito._Lambda$__1(Object a0, EventArgs a1) in C:\Users\Propietario\AppData\Local\Temp\Temporary ASP.NET Files\sipro\421e3836\3ed8522\App_Web_qn0tr4q0.0.vb :0
System.Web.UI.Control.OnDataBinding(EventArgs e) +91
System.Web.UI.WebControls.DataBoundControl.OnDataS ourceViewSelectCallback(IEnumerable data) +54
System.Web.UI.DataSourceView.Select(DataSourceSele ctArguments arguments, DataSourceViewSelectCallback callback) +33
System.Web.UI.WebControls.DataBoundControl.Perform Select() +143
System.Web.UI.WebControls.BaseDataBoundControl.Dat aBind() +74
System.Web.UI.WebControls.GridView.DataBind() +4
System.Web.UI.WebControls.BaseDataBoundControl.Ens ureDataBound() +66
System.Web.UI.WebControls.CompositeDataBoundContro l.CreateChildControls() +75
System.Web.UI.Control.EnsureChildControls() +102
System.Web.UI.Control.PreRenderRecursiveInternal() +42
System.Web.UI.Control.PreRenderRecursiveInternal() +175
System.Web.UI.Control.PreRenderRecursiveInternal() +175
System.Web.UI.Control.PreRenderRecursiveInternal() +175
System.Web.UI.Control.PreRenderRecursiveInternal() +175
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2496