1,在aspx中加

<script type="text/javascript">
    var prevselitem=null;
    function selectx(row)
    {
        if(prevselitem!=null)
        {
            prevselitem.style.backgroundColor='#ffffff';
        }
        row.style.backgroundColor='PeachPuff';
        prevselitem=row;   
    }
</script>

2,在RowDataBound事件中加

if (e.Row.RowType == DataControlRowType.DataRow)
    {
        e.Row.Attributes.Add("onmouseover", "if(this!=prevselitem){this.style.backgroundColor='#Efefef'}");//
当鼠标停留时更改背景色 
        e.Row.Attributes.Add("onmouseout", "if(this!=prevselitem){this.style.backgroundColor='#ffffff'}");//
当鼠标移开时还原背景色 
        e.Row.Attributes.Add("onclick", e.Row.ClientID.ToString() + ".checked=true;selectx(this)");
    }

相关文章:

  • 2022-01-14
  • 2022-12-23
  • 2022-12-23
  • 2021-11-15
  • 2022-12-23
  • 2021-06-06
  • 2022-01-21
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-06-16
  • 2022-12-23
  • 2022-12-23
  • 2021-08-26
  • 2022-12-23
  • 2021-10-16
相关资源
相似解决方案