GridView Mouse Over Row Highlighting

Posted: September 27, 2010 in ASP.Net

If you are looking at creating mouse over row highlighting on a GridView control, you can try the following:
ASP.Net (Code Behind)
Add the following attributes for each row in the GridView control:

 ' Routine for when each row is created for the gridview
 Protected Sub p_grd_site_details_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs)
     If e.Row.RowType = DataControlRowType.DataRow Then
         e.Row.Attributes.Add("onmouseover", "this.className='grd_mouse_over';'pointer';")
         e.Row.Attributes.Add("onmouseout", "this.className='grd_mouse_out';")
     End If
 End Sub

Add the following styles:

.grd_mouse_out{background-color: #FFFFFF;}

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s