實現審核狀態顯示,選中行顏色變化功能。

效果圖——
實現審核狀態顯示,并選中行顏色變化功能。
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//高亮顯示指定行
e.Row.Attributes.Add("onMouseOver", "Color=this.style.backgroundColor;this.style.backgroundColor='#31cb29'");
e.Row.Attributes.Add("onMouseOut", "this.style.backgroundColor=Color;");
//設置審核狀態,并且設置相應的顏色
if (e.Row.Cells[5].Text == "False")
{
e.Row.Cells[5].ForeColor = Color.Red;
e.Row.Cells[5].Text = "未審核";
}
else
{
e.Row.Cells[5].ForeColor = Color.Blue;
e.Row.Cells[5].Text = "已審核";
}
}
}
浙公網安備 33010602011771號