通过RowDTbound事件给表格定义不同的样式显示
protected void rowDTbound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
TableCell mytc = e.Row.Cells[6];
Single _f = Convert.ToSingle(mytc.Text);
TableCell mytc2 = e.Row.Cells[19];
Single _f2 = Convert.ToSingle(mytc2.Text);
if (_f > 0)
{
mytc.ForeColor = System.Drawing.Color.Red;
//mytc.CssClass = "mytcred";
}
if (_f2 > 0)
{
mytc2.ForeColor = System.Drawing.Color.DarkRed;
mytc2.CssClass = "mytcred";
}
else {
mytc2.ForeColor = System.Drawing.Color.Green;
mytc2.CssClass = "mytcgreen";
}
}
}