By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,870 Members | 1,224 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,870 IT Pros & Developers. It's quick & easy.

Highlighting DataGrid Rows on mouseOver

P: n/a
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?
Nov 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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.cur sor='hand'")
e.Item.Attributes.Add("onmouseout",
"this.style.backgroundColor='white';")
End If
End Sub

Hope it helps!!
Patrick

"WebMatrix" wrote:
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?

Nov 18 '05 #2

P: n/a
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!

"Patrick.O.Ige" wrote:
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.cur sor='hand'")
e.Item.Attributes.Add("onmouseout",
"this.style.backgroundColor='white';")
End If
End Sub

Hope it helps!!
Patrick

"WebMatrix" wrote:
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?

Nov 18 '05 #3

P: n/a
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

"WebMatrix" wrote:
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!

"Patrick.O.Ige" wrote:
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.cur sor='hand'")
e.Item.Attributes.Add("onmouseout",
"this.style.backgroundColor='white';")
End If
End Sub

Hope it helps!!
Patrick

"WebMatrix" wrote:
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?

Nov 18 '05 #4

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

Eliyahu

"WebMatrix" <We*******@discussions.microsoft.com> wrote in message
news:69**********************************@microsof t.com...
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!

"Patrick.O.Ige" wrote:
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.cur sor='hand'")
e.Item.Attributes.Add("onmouseout",
"this.style.backgroundColor='white';")
End If
End Sub

Hope it helps!!
Patrick

"WebMatrix" wrote:
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?

Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.