Highlighting DataGrid Rows on mouseOver

G

Guest

Hello,

I need to extend functionality of ASP.NET datagrid. Onmouse over, the whole
row needs to be highlighted. OnClick highlighted color must remain, and the
value of one of the columns must be set to innerHTML property of a <div> tag
(no postBack).
Has anyone done anything like that?
 
G

Guest

Yep try using ItemCreated like below:-

Sub MenuGrid_ItemCreated(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridItemEventArgs) Handles MenuGrid.ItemCreated
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Or e.Item.ItemType = ListItemType.SelectedItem
Then
e.Item.Attributes.Add("onmouseover",
"this.style.backgroundColor='beige';this.style.cursor='hand'")
e.Item.Attributes.Add("onmouseout",
"this.style.backgroundColor='white';")
End If
End Sub

Hope it helps!!
Patrick
 
G

Guest

Thanks for the prompt reply. I think yoiur code will work for highlighting.
One more question; in this ItemCreated event, can I access a value of a
specific column?
Thank you!
 
G

Guest

Yes WebMatrix..
For example by doing (For the first Cell!!):-

e.Item.Cells(1).Attributes.Add("onmouseover",
"this.style.backgroundColor='#DDEEFF'")
e.Item.Cells(1).Attributes.Add("onmouseout",
"this.style.backgroundColor='white'")

Enjoy
Patrick
 
E

Eliyahu Goldin

If it is a bound column, the value will become known in ItemDataBound event.
You can move all this code over there.

Eliyahu
 

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,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top