DotNetJaps

For the ASP.NET,By the ASP.NET and Of the ASP.NET

Sponsors

News


My Another Blog

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';");
}
}

Comments

Steve Smith said:

Why not just use CSS?

# January 28, 2008 12:14 PM

Jalpesh Vadgama said:

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

# January 30, 2008 4:51 AM

satty said:

See this link for using CSS in datagrid

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

# December 5, 2008 2:04 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)