yuezhonghu

悠然现南山...
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

鼠标在datalist、gridview等表格的效果

Posted on 2008-01-15 14:41  .狐狸血.  阅读(158)  评论(0编辑  收藏  举报

GridView:
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=e");
            e.Row.Attributes.Add("onmouseover", "e=this.style.backgroundColor;this.style.backgroundColor=\"" + "#EFF3F7" + "\"");
        }
    }
DataList:
ItemTemplate模板列中把Table属性设置onmouseover和onmouseout,配合如下JS代码:
<script>  
  var   classname   =   ""  
  function   TbOnmouseover(val)  
  {  
  classname   =   val.className    
  val.className   =   "DataListSelecte"  
  }  
   
  function   TbOnmouseout(val)  
  {  
  val.className   =   classname  
  }  
  </script>