当鼠标在Gridview停留时更改行背景色
主要功能是当鼠标在Gridview停留时更改行背景色。
谁能给我讲解下这个错误,谢谢!! --------------------编程问答--------------------
protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//鼠标经过时,行背景色变
e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#00A9FF'");
//鼠标移出时,行背景色变
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='#FFFFFF'");
}
}
}
注意是GridView_RowDataBound这个事件里。
GridViewRowEventArgs e 这个也要注意 --------------------编程问答--------------------
2说得对 --------------------编程问答--------------------
--------------------编程问答--------------------
$(function(){
$('#<%=GridView1.ClientID %> tr:gt(0)').addClass('GridItem').css("cursor","hand")
.hover(function(){var r=$('#ResultTable tr:gt(0)').index($(this))+1;if(selRow!=r){$(this).css('backgroundColor','honeydew');}},function(){$(this).css('backgroundColor',''); })
.click(function(){var r=$('#ResultTable tr:gt(0)').index($(this))+1;$(this).css('backgroundColor','');selRow=r;$(this).addClass('clickBg').siblings().removeClass('clickBg'); });
});
GridView_RowDataBound这是GridViews的事件。2楼是对的。 --------------------编程问答-------------------- 我以前用2楼的方法,不过现在用DEV,不这么用了。。。 --------------------编程问答-------------------- protected void GridView_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//鼠标经过时,行背景色变
e.Row.Attributes.Add("onMouseOver", "this.style.backgroundColor='#00A9FF'");
//鼠标移出时,行背景色变
e.Row.Attributes.Add("onMouseOut", "this.style.backgroundColor='#FFFFFF'");
}
}
}
一定要注意大小写哟!
补充:.NET技术 , .NET Framework