我在asp.net网页上有一个gridview,并且该行的背景颜色根据特定单元格中的数据而改变,但网格的第一行没有改变。为什么是这样? 这是我用来改变颜色的代码:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
int StationStatus1 = Int32.Parse(GridView1.DataKeys[e.Row.RowIndex].Values[0].ToString());
foreach (GridViewRow row in GridView1.Rows)
{
switch (StationStatus1)
{
case 0:
case 3:
e.Row.BackColor = System.Drawing.Color.Red;
break;
case 12:
e.Row.BackColor = System.Drawing.Color.Blue;
break;
default:
e.Row.BackColor = System.Drawing.Color.White;
break;
任何帮助都会受到高度关注。感谢