Saturday, July 4, 2009

Highlighting Rows in a GridView


-------------

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load ( object sender, EventArgs e )
{
bindGrid();
}

protected void GridView1_RowDataBound ( object sender, GridViewRowEventArgs e )
{
if ( e.Row.RowType == DataControlRowType.DataRow )
{
if ( e.Row.RowType == DataControlRowType.DataRow )
{
e.Row.Attributes.Add ( "onmouseover", "this.savedColor=this.style.backgroundColor;this.style.backgroundColor='Yellow'" );
e.Row.Attributes.Add ( "onmouseout", "this.style.backgroundColor=this.savedColor;" );
}
}
}
}

No comments: