Jun 02

Hightlight GridView row on mouse over event

ASP.Net 74 Comments »

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Code is self explanatory. No explanation is needed. Try to run this code and see the result yourself. :) 

protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)

{

// only apply changes if its DataRow

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

{

// when mouse is over the row, save original color to new attribute, and change it to highlight yellow color

e.Row.Attributes.Add("onmouseover", "this.originalstyle=this.style.backgroundColor;this.style.backgroundColor='SkyBlue'");

// when mouse leaves the row, change the bg color to its original value

e.Row.Attributes.Add("onmouseout","this.style.backgroundColor=this.originalstyle;");

//Color.

}

}



[KickIt] [Dzone] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

Tags: ,