//根据条件着色GridViewRow
protected void gvCarApply_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string strFlag = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "flag"));
if (strFlag == "Y")
{
e.Row.BackColor = Color.GreenYellow;
}
else if (strFlag == "N")
{
e.Row.BackColor = Color.Red;
}
//当鼠标停留时更改背景色
e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#00A9FF'");
//当鼠标移开时还原背景色
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
}
}
protected void gvCarApply_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string strFlag = Convert.ToString(DataBinder.Eval(e.Row.DataItem, "flag"));
if (strFlag == "Y")
{
e.Row.BackColor = Color.GreenYellow;
}
else if (strFlag == "N")
{
e.Row.BackColor = Color.Red;
}
//当鼠标停留时更改背景色
e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#00A9FF'");
//当鼠标移开时还原背景色
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
}
}