protected
void
GridView1_RowDataBound(
object
sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add( " onmouseover " , " c=this.style.backgroundColor;this.style.backgroundColor='#B9D3EE' " );
e.Row.Attributes.Add( " onmouseout " , " this.style.backgroundColor=c " );
}
}
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add( " onmouseover " , " c=this.style.backgroundColor;this.style.backgroundColor='#B9D3EE' " );
e.Row.Attributes.Add( " onmouseout " , " this.style.backgroundColor=c " );
}
}
也可以利用JQUERY实现相关的功能
//
变色
$( " tr " ).filter( function (){
return $( ' td ' , this ).length && ! $( ' table ' , this ).length
}).css({ background: " ffffff " }).hover(
function (){$( this ).css({background: " #C1DAD7 " });},
function (){$( this ).css({background: " #ffffff " });}
);
$( " tr " ).filter( function (){
return $( ' td ' , this ).length && ! $( ' table ' , this ).length
}).css({ background: " ffffff " }).hover(
function (){$( this ).css({background: " #C1DAD7 " });},
function (){$( this ).css({background: " #ffffff " });}
);