对一个页面我使用了如下的样式表
TD
{
 background-color: #E4E8EF;
}
再使用
private void Flow_dg_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemIndex<0) return;
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
e.Item.Attributes.Add("onmouseover","currentcolor=this.style.backgroundColor;this.style.backgroundColor='48d1cc'");
e.Item.Attributes.Add("onmouseout","this.style.backgroundColor=currentcolor");
}
}
DataGrid并不变色,已经知道是样式表的问题了,那么如果不改变样式表,那么能实现颜色变化吗?

解决方案 »

  1.   

    Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles DataGrid1.ItemDataBound
            If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
                e.Item.Attributes.Add("onmouseover", "javascript:this.style.backgroundColor='#ddf3dd';")
                e.Item.Attributes.Add("onmouseout", "javascript:this.style.backgroundColor='white';")
            End If
        End Sub
      

  2.   

    http://blog.csdn.net/canbo/admin/Referrers.aspx?EntryID=320132
      

  3.   

    canbo(小李飞刀),你给的路径打不开啊.
      

  4.   

    http://www.cnblogs.com/jhtchina/articles/115543.html