如果你使用的是EasyUi的话。可以去改他里面的样式。
不然的话。你就用onmouseover 和onmouseout 去改变它每行的样式。
在gridview控件右上方有个箭头的,里面鼠标单击可以选择编辑列选项,里面有每个列的设置,包括颜色,也可以直接套用模板。
public static void OnMouseOver(GridViewRowEventArgs e, string MouseOverColor)
{
ListItemType itemType = (ListItemType)e.Row.RowType;
if (itemType == ListItemType.Item)
{
e.Row.Attributes["onmouseout"] = "javascript:this.style.backgroundColor='#ffffff';";
e.Row.Attributes["onmouseover"] = "javascript:this.style.backgroundColor='" + MouseOverColor + "';cursor='hand';";
}
else if (itemType == ListItemType.AlternatingItem)
{
e.Row.Attributes["onmouseout"] = "javascript:this.style.backgroundColor='#ffffff';";
e.Row.Attributes["onmouseover"] = "javascript:this.style.backgroundColor='" + MouseOverColor + "';cursor='hand';";
}
}
datagrid控件里有许多属性的,你可以根据不同的属性来设置行背景色,如