mouseover highlight of datagrid row

  • Thread starter Thread starter TJS
  • Start date Start date
T

TJS

trying to use this code for mouseover highlight of row but it is not working
on the datagrid, nothing happens.
Page compiles without errors but no highlighting effects take place.

can anyone tell me what is missing ?



Sub Grid_ItemDataBound(ByVal sender As Object, ByVal e As
DataGridItemEventArgs)

If e.Item.ItemType = ListItemType.Item Or _
e.Item.ItemType = ListItemType.AlternatingItem Then
'---------------------------------------------------
' Add the OnMouseOver and OnMouseOut method to the Row of DataGrid
'---------------------------------------------------
e.Item.Attributes.Add("onmouseover",
"this.style.backgroundColor='Silver'")
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='White'")
End If

End Sub
 
Hi
The code is right
Please check the following
1. The 'asp:DataGrid ID' tag should have an ItemDataBound event mentioned
eg: <asp:DataGrid ID="ItemsGrid" AutoGenerateColumns="False" OnItemDataBound = "ItemsGrid_Bound" Runat="server"

2. Manually register the event-handling method (Grid_ItemDataBound in your case) for the ItemDataBound event of the data grid

It worked for me. Only diff is that my code was in C#

HT
Regards
-am
 
Back
Top