Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Highlighting DataGrid rows with Java 1

Status
Not open for further replies.

Isadore

Technical User
Feb 3, 2002
2,167
US
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:

<asp:DataGrid
....
....
OnItemDataBound=&quot;dgGroups_ItemDataBound&quot;
....
....

A detailed discussion and other techniques of using Mouse Over for both DataGrid Rows and Columns see:

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top