回 帖 发 新 帖 刷新版面

主题:关于鼠标悬停

protected void DataGrid1_ItemDataBound(object sender, DataGridItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                e.Item.Attributes.Add    ("onmouseover", "c=this.style.backcgroundColor;this.style.backgroundColor='#6699ff'");
                e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
            }
        }

这段代码是想实现鼠标悬停在DataGrid的一般项和交替项上时,改变背景颜色。
我先用c把原来的背景色取出,当移开鼠标时,再赋值给背景。
现在的问题是:鼠标移开时,背景色仍然是改变后的颜色,变不回来了;如果我不用c,而是直接用16进制的代码赋值颜色,就可以了。
怎么样去定义这个c,让他可以赋值回去呢?

回复列表 (共2个回复)

沙发

试下:
方法1:
var c=this.style.backcgroundColor;
方法2:
把c变成this.c

板凳

不行饿。。。。

我来回复

您尚未登录,请登录后再回复。点此登录或注册