简体   繁体   中英

How can I use greater than on Gridview text?

I have a Gridview like this:

在此输入图像描述

I need to change backcolor when Zero line greater than %10.

I tried like this (for just 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;
      }
   }
}

I can't convert Row.Cells[i].Text to Int because of % . How can I use greater than 10 for backcolor?

just replace

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

with

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM