根据条件着色GridViewRow

xiaoxiao2026-06-05  16

//根据条件着色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"); } }
转载请注明原文地址: https://www.6miu.com/read-5049629.html

最新回复(0)