如何在Gridview文本上使用大于?

时间:2015-10-19 13:11:50

标签: c# asp.net gridview

我有一个像这样的Gridview:

enter image description here

Zero行大于%10时,我需要更改背景色。

我试过这样(只有15%):

if (e.Row.Cells[0].Text == "Zero")
{
   for (int i = 0; i < e.Row.Cells.Count; i++)
   {
      if (e.Row.Cells[i].Text == "15%")
      {
         e.Row.Cells[i].BackColor = System.Drawing.Color.LightCoral;
      }
   }
}

由于Row.Cells[i].Text,我无法将Int转换为%。如何使用大于10的背景颜色?

1 个答案:

答案 0 :(得分:3)

只需替换

if (e.Row.Cells[i].Text == "15%")

if (int.Parse(e.Row.Cells[i].Text.Trim('%'))>10)