Foros del Web » Programación para mayores de 30 ;) » .NET »

resaltar datos onMouseOver

Estas en el tema de resaltar datos onMouseOver en el foro de .NET en Foros del Web. Hola todos: tengo un datagrid cargado con datos, deseo saber si es posible resaltar cada fila cuando el usuario pasa el mouse sobre ella. es ...
  #1 (permalink)  
Antiguo 22/03/2005, 08:35
 
Fecha de Ingreso: marzo-2005
Mensajes: 90
Antigüedad: 20 años
Puntos: 0
resaltar datos onMouseOver

Hola todos:
tengo un datagrid cargado con datos, deseo saber si es posible resaltar cada fila cuando el usuario pasa el mouse sobre ella. es posible? Les adjunto el código
desde ya muchas gracias
salu2

codigo:
Sub page_load

dim codigo as string
codigo = session("usuario")

dim miFecha as string
miFecha= datetime.now.tostring("dd-MM-yyyy")

'evento
BindGrid

response.write("<p align='center'><font face= Verdana size=4><b>MANTENIMIENTO DE USUARIOS</b></font></p>")
response.write("<p align='left'><font face='Verdana'>Bienvenido:&nbsp;<b>"+codigo+"</b> </font></p>")
response.write("<p align='left'><font face='Verdana'>Hoy es:&nbsp;<b>"+miFecha+"</b></font></p>")

End Sub
'evento cambiar de pagina
Sub Page_Change(sender As Object, e As DataGridPageChangedEventArgs)
dim start as Integer
start = MyDataGrid.CurrentPageIndex * MyDataGrid.PageSize
MyDataGrid.CurrentPageIndex = e.NewPageIndex
BindGrid
End Sub
'conexion, SQL y Grilla
Sub BindGrid()
dim strConexion as string = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=C:\acontecer.mdb"
dim ds as DataSet = new DataSet()
dim adapter as OledbDataAdapter = new OledbDataAdapter("Select * from Suscripciones", strConexion)
adapter.Fill(ds,"Suscripciones")
MyDataGrid.DataSource=ds.Tables("Suscripciones").D efaultView
MyDataGrid.DataBind()

End Sub

'rutinas de los botones
Sub Button1_Click(sender As Object, e As EventArgs)
response.redirect("formaltas.htm")
End Sub

Sub Button2_Click(sender As Object, e As EventArgs)
session.abandon
response.redirect("ingreso.htm")
End Sub

Sub Button3_Click(sender As Object, e As EventArgs)
dim miDepto as string
miDepto = TextoDepto.text
response.redirect("filtro_dep.aspx?cod="+miDepto)
End Sub

Sub Button4_Click(sender As Object, e As EventArgs)
dim miApe as string
miApe = TextoApellido.text
response.redirect("filtro_ape.aspx?cod="+miApe)
End Sub

Sub Button5_Click(sender As Object, e As EventArgs)
dim miNom as string
miNom = TextoNombre.text
response.redirect("filtro_nom.aspx?cod="+miNom)
End Sub
  #2 (permalink)  
Antiguo 22/03/2005, 09:32
Avatar de RootK
Moderador
 
Fecha de Ingreso: febrero-2002
Ubicación: México D.F
Mensajes: 8.004
Antigüedad: 23 años, 1 mes
Puntos: 50
Puedes usar el ItemDataBound de tu grid....

sería algo así:

Cita:
Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)

If e.Item.ItemType = ListItemType.AlternatingItem Or _
e.Item.ItemType = ListItemType.Item Then
e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='red'")
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='white'")

End If
End Sub
Salu2
__________________
Nadie roba nada ya que en la vida todo se paga . . .

Exentrit - Soluciones SharePoint & Net
  #3 (permalink)  
Antiguo 22/03/2005, 10:07
 
Fecha de Ingreso: marzo-2005
Mensajes: 90
Antigüedad: 20 años
Puntos: 0
gracias rootk, no se si lo estoy haciendo bien mas no me funciona
coloque este codigo que me pasaste en el anterior, solo modifique el nombre de el datagrid esta bien asi?, deberia funcionar de esta manera?
Sub MyDataGrid_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)

If e.Item.ItemType = ListItemType.AlternatingItem Or _
e.Item.ItemType = ListItemType.Item Then
e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='red'")
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='white'")

End If

End Sub
  #4 (permalink)  
Antiguo 22/03/2005, 10:10
Avatar de RootK
Moderador
 
Fecha de Ingreso: febrero-2002
Ubicación: México D.F
Mensajes: 8.004
Antigüedad: 23 años, 1 mes
Puntos: 50
Por la sintaxis que tienes me imagino que estas usando web matrix, o algo por el estilo, entonces te faltaría agreagar ésto a tu datagrid.

Cita:
<asp:DataGrid id="MyDataGrid" runat="server" OnItemCommand="MyDataGrid_ItemDataBound"
...
..
Para que enlaces el evento de tu grid..
  #5 (permalink)  
Antiguo 22/03/2005, 11:25
 
Fecha de Ingreso: marzo-2005
Mensajes: 90
Antigüedad: 20 años
Puntos: 0
Si estoy usando el web Matrix, disculpa que no te lo dije, le agregue el codigo para enlazar y me da el siguiente error:

Compiler Error Message: BC30408: Method 'Public Sub MyDataGrid_ItemDataBound(sender As Object, e As System.Web.UI.WebControls.DataGridItemEventArgs)' does not have the same signature as delegate 'Delegate Sub DataGridCommandEventHandler(source As Object, e As System.Web.UI.WebControls.DataGridCommandEventArgs )'.

Line 113: <!-- Insert content here -->
Line 114: <p align="left">
Line 115: <ASP:DataGrid id="MyDataGrid" runat="server" OnItemCommand="MyDataGrid_ItemDataBound" Font-Names="Verdana" BackColor="White" GridLines="Vertical" BorderStyle="None" AllowPaging="True" PageCount="1" PagerStyle-Mode="NumericPages" PagerStyle-HorizontalAlign="Center" OnPageIndexChanged="Page_Change" BorderColor="#999999" BorderWidth="1px" CellPadding="3" Font-Name="Verdana" Font-Size="8pt" HeaderStyle-BackColor="#aaaadd" AlternatingItemStyle-BackColor="#B8E8FE" width="100%">
Line 116: <FooterStyle forecolor="Black" backcolor="#CCCCCC"></FooterStyle>
Line 117: <HeaderStyle font-bold="True" forecolor="White" backcolor="#000084"></HeaderStyle>
  #6 (permalink)  
Antiguo 22/03/2005, 12:59
Avatar de HenrydeSousa  
Fecha de Ingreso: septiembre-2004
Ubicación: Venezuela
Mensajes: 300
Antigüedad: 20 años, 6 meses
Puntos: 2
Hola Facha, de verdad no lei tu problem very well, pero aqui te dejo esta url por si te sirve, sino bueno ojala le sirva a alguien más.
http://www.c-sharpcorner.com/Code/20...SideEvents.asp
  #7 (permalink)  
Antiguo 22/03/2005, 13:38
 
Fecha de Ingreso: marzo-2005
Mensajes: 90
Antigüedad: 20 años
Puntos: 0
gracias henry, estaba probando con el link que me pasaste pero me da este error:

Compiler Error Message: BC30506: Handles clause requires a WithEvents variable.
Line 40:
Line 41: Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, _
Line 42: ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemDataBound
Line 43: Dim dv As DataView = DataGrid1.DataSource
Line 44: Dim dcCol As DataColumn
  #8 (permalink)  
Antiguo 22/03/2005, 13:49
Avatar de HenrydeSousa  
Fecha de Ingreso: septiembre-2004
Ubicación: Venezuela
Mensajes: 300
Antigüedad: 20 años, 6 meses
Puntos: 2
si estas programando en vb recuerda que tus controles los declaras asi por ejemplo:
protected withevents label as System.Web.UI.WebControl.Label y no de esta manera:
protected label as System.Web.UI.WebControl.Label, tu problema es ese te falta el Withevents, revisalo en donde declaras tus controles. Saludos...
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 06:48.