I know this post is outdated, but I have a much simpler solution. Create your control using:
<RowStyle CssClass="GridRow" />
somewhere inside asp: GridView tags.
Then add the following to the client page of the script (I am using jQuery)
$(document).ready(function () { $('.GridRow').click(ChangeSelectedRow); }); function ChangeSelectedRow(evt) { $('.GridRow').removeClass('GridSelectedRow'); $(this).addClass('GridSelectedRow'); }
Finally, in your stylesheet, define the style you want for GridSelectedRow. Something like the code shown below. An important tag is needed to make sure that it overrides the previous background color settings.
.GridSelectedRow { background-color: #E0F76F !important; }
source share