-
1
- #1
In case you haven't come across this technique, its a pretty useful one demonstrating one of the uses for the "OnItemDataBound" event of the DataGrid. Places Mouse Over Java on the DataGrid rows - allowing you to change colors for highlighting. You can also activate message box, etc...
The Subroutine in the code behind is:
Sub dgGroups_ItemDataBound(sender As Object, e As System.Web.UI.WebControls.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='Wheat'"
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='LightSteelBlue'"
End If
End Sub
and in the def of the DataGrid:
<aspataGrid
....
....
OnItemDataBound="dgGroups_ItemDataBound"
....
....
A detailed discussion and other techniques of using Mouse Over for both DataGrid Rows and Columns see:
The Subroutine in the code behind is:
Sub dgGroups_ItemDataBound(sender As Object, e As System.Web.UI.WebControls.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='Wheat'"
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='LightSteelBlue'"
End If
End Sub
and in the def of the DataGrid:
<aspataGrid
....
....
OnItemDataBound="dgGroups_ItemDataBound"
....
....
A detailed discussion and other techniques of using Mouse Over for both DataGrid Rows and Columns see: