Highlighting Gridview Row on Mouse Over which does not have Alternating Row Color.

Posted by vishalneeraj-24503 under ASP.NET category on | Points: 40 | Views : 727
Suppose,we have a Gridview called grid_project_details as below:-
<asp:GridView ID = "grid_project_details" runat = "server" 
OnRowCreated = "grid_project_details_RowCreated">

Now in the OnRowCreated event we have to write below code:-
protected void grid_project_details_RowCreated(object sender, GridViewRowEventArgs e)
if (e.Row.RowType == DataControlRowType.DataRow)
//On Mouse Over Highlight Row set row color to yellow
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='yellow'");

//On Mouse out restore default row color i.e. white color
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='white'");

So,when we point our mouse on any row,color will be yellow and point out,then reset color as white.

Comments or Responses

Login to post response