GridView中如何根据某一列值改变行的颜色 [问题点数:30分,结帖人wsdydmw]
protected
void
GridView1_RowDataBound(
object
sender, GridViewRowEventArgs e)
{
if
(e.Row.RowIndex >= 0)
{
double
number1 =
double
.Parse(e.Row.Cells[2].Text.ToString());
//数量1
double
number2 =
double
.Parse(e.Row.Cells[5].Text.ToString());
//数量2
if
(number1 < number2 )
{
e.Row.BackColor = System.Drawing.Color.SkyBlue;
//显示颜色,可自定义
}
}
}