在RowDataBoundow做設定
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if(e.Row.RowType == DataControlRowType.DataRow)
{
int salary = Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "AnnualSalary"));
if(salary > 70000)
{
e.Row.BackColor = System.Drawing.Color.Blue;
e.Row.ForeColor = System.Drawing.Color.White;
}
}
}