日期:2014-05-18  浏览次数:21184 次

GridView行颜色
怎么设置当鼠标点击GridView某一行时,那么这行显示底色为黄色,当鼠标点击GridView另一行时,上次点击的那行底色还原为以前的颜色,被点击的行底色设置为黄色.

------解决方案--------------------
RowEnter RowLeave这两个事件
------解决方案--------------------
假设原来是white色,在RowDataBound事件里写:
C# code
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        e.Row.Attributes["onclick"] = "var rows=this.parentNode.rows;for(var i=0;i<rows.length;i++)rows[i].style.background='white';this.style.background='yellow';";
    }

------解决方案--------------------
RowClick吧。
CurrentRow.BackColor
------解决方案--------------------
探讨
假设原来是white色,在RowDataBound事件里写:

C# code
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
e.Row.Attributes["onclick"] = "var rows=this.parentNode.rows……

------解决方案--------------------
<script>
var oldClr;
function chgClr(obj){
var rows;
oldClr=obj.style.backgroundColor;
rows=this.parentNode.rows;
for(var i=0;i<rows.length;i++){ 
rows[i].style.backgroundColor=oldClr;
obj.style.backgroundColor='yellow';
}
}
</script>

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
e.Row.Attributes.Add["onclick","chgClr(this)"];
}
------解决方案--------------------
完整的代码
http://dotnet.aspx.cc/file/Change-GridView-Row-Background-Color-When-Click-Row.aspx
------解决方案--------------------
探讨
完整的代码
http://dotnet.aspx.cc/file/Change-GridView-Row-Background-Color-When-Click-Row.aspx

------解决方案--------------------
探讨
完整的代码
http://dotnet.aspx.cc/file/Change-GridView-Row-Background-Color-When-Click-Row.aspx