Geeks With Blogs

News

Microsoft MVP


Moderator at CodeASP.NET


Quiz Master




free counters
Free counters
Added on January 19,2012


Follow Me @vmsdurano

A bit About Me



Disclaimer
The opinions expressed herein are my own personal opinions and does not represent the opinions of my employers. Nor does it represent the opinion of my dog, because I don’t have one.


Vinz' Blog (ProudMonkey) "Code, Beer and Music ~ my way of being a programmer"

Here’s an example on how to highlight 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:

That simple!

 

Technorati Tags: ,,
Posted on Tuesday, February 24, 2009 5:22 PM ASP.NET , Tips&Tricks , GridView | Back to top


Comments on this post: Tip/Trick: Highlighting GridView Rows on Mouseover

# re: Tip/Trick: Highlighting GridView Rows on Mouseover
Requesting Gravatar...
I'm new at this and I'm using VB.Net. I was wondering if you could maybe translate this to VB.Net?
Left by Ramon on Aug 05, 2011 12:01 AM

comments powered by Disqus

Copyright © Vincent Maverick Durano | Powered by: GeeksWithBlogs.net | Join free