I need to change color if string
is empty
it set to red color
foreach (TableCell cell in e.Row.Cells)
{
if (cell.Equals(" ")||cell.Equals(string.Empty)||string.IsNullOrWhiteSpace(cell.ToString()))//if (cell.ToString() == " ")
{
cell.BackColor = Color.Red;
}
else
{
cell.BackColor = Color.White;
}
}
[ ]
foreach (TableCell cell in e.Row.Cells)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string text = cell.Text.Trim();
cell.BackColor = (String.IsNullOrEmpty(text) || text == " ") ? Color.Red : Color.White;
}
}
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.