Vinz' Blog

"Code, Beer and Music" ~ my way of being a programmer!
posts - 124, comments - 366, trackbacks - 0

My Links

News

Archives

Image Galleries

Tip/Trick: Highlighting GridView Rows on Mouseover

Here’s an example on how to hightlight GridView rows on mousover at RowCreated or RowDataBound event of GridView by simply adding an attributes to the row.

Here’s the code block:

protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)

{

        string onmouseoverStyle = "this.style.backgroundColor='blue'";

        string onmouseoutStyle = "this.style.backgroundColor='white'";

        if (e.Row.RowType == DataControlRowType.DataRow)

        {

            e.Row.Attributes.Add("onmouseover", onmouseoverStyle);

            e.Row.Attributes.Add("onmouseout", onmouseoutStyle);

        }

}

 

Here’s the output below:

Happy Coding! :)

Print | posted on Tuesday, February 24, 2009 5:22 PM |

Feedback

No comments posted yet.
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 
 

Powered by: