我有一个像这样的Gridview:
当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的背景颜色?
答案 0 :(得分:3)
只需替换
if (e.Row.Cells[i].Text == "15%")
带
if (int.Parse(e.Row.Cells[i].Text.Trim('%'))>10)