对一个页面我使用了如下的样式表
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并不变色,已经知道是样式表的问题了,那么如果不改变样式表,那么能实现颜色变化吗?
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并不变色,已经知道是样式表的问题了,那么如果不改变样式表,那么能实现颜色变化吗?
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