mouseover highlight of datagrid row

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
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top