Mouse Hover effect on asp.net datagrid.

Here is the code for mouse hover effect in ASP.NET using C#.

I have written a another code for mouse hover effect in asp.net data gird. You can do both for alternating item and item rows.

First You have to create a item created event of datagrid and paste the following...


private void datagrid_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if (e.Item.ItemType==ListItemType.AlternatingItem)
{
e.Item.Attributes.Add("OnMouseOver", "this.style.backgroundColor = 'lightblue';");
e.Item.Attributes.Add("OnMouseOut", "this.style.backgroundColor = '#E5F2FA';");
}
else if(e.Item.ItemType==ListItemType.Item)
{
e.Item.Attributes.Add("OnMouseOver", "this.style.backgroundColor = 'lightblue';");
e.Item.Attributes.Add("OnMouseOut", "this.style.backgroundColor = 'white';");
}
}

Published Monday, January 28, 2008 8:05 PM by Jalpesh P. Vadgama
Filed under:

Comments

# re: Mouse Hover effect on asp.net datagrid.

Monday, January 28, 2008 12:14 PM by Steve Smith

Why not just use CSS?

# re: Mouse Hover effect on asp.net datagrid.

Wednesday, January 30, 2008 4:51 AM by Jalpesh Vadgama

How you can add the style shee to each item in datagrid?.

# re: Mouse Hover effect on asp.net datagrid.

Friday, December 05, 2008 2:04 PM by satty

See this link for using CSS in datagrid

www.codeproject.com/.../datagrid_extend_functions.aspx

Leave a Comment

(required) 
(required) 
(optional)
(required)