The javascript:
function highlight(tableRow, active) { if (active) { tableRow.style.backgroundColor = '#cfc'; } else { tableRow.style.backgroundColor = '#fff'; } } function link(Url) { document.location.href = Url; }
The Databound event of the GridView:
protected void GridView1_DataBound(object sender, EventArgs e) { foreach (GridViewRow grow in GridView1.Rows) { grow.Attributes["onmouseover"] = "highlight(this, true);"; grow.Attributes["onmouseout"] = "highlight(this, false);"; HttpResponse myHttpResponse = Response; HtmlTextWriter myHtmlTextWriter = new HtmlTextWriter(myHttpResponse.Output); grow.Attributes.AddAttributes(myHtmlTextWriter); } }