BOEING39
asked on
GRIDVIEW CELL FONT COLOR BASED ON CONDITION
I have the following code behind where I need to change the font color based on a condition of column14 being "High Priority" where the Font is changed to red.
else if (e.Row.Cells[14].Text == "High Priority")
{
e.Row.BackColor = System.Drawing.Color.Light SkyBlue ;
}
Home1All.aspx.cs
Home1All.aspx
else if (e.Row.Cells[14].Text == "High Priority")
{
e.Row.BackColor = System.Drawing.Color.Light
}
Home1All.aspx.cs
Home1All.aspx
using System.Drawing;
e.Rows[rowNr].Cells[14].Fo reColor = Color.Red;
e.Rows[rowNr].Cells[14].Fo
or
this.dataGridView1.Default CellStyle. SelectionB ackColor = Color.Red;
this.dataGridView1.Default
e.Row.ForeColor=Color.Red;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Tried the different variations listed. No joy.
protected void GridView1_RowDataBound(obj ect sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow )
if (e.Row.Cells[14].Text == "AOG" || e.Row.Cells[14].Equals(DBN ull.Value) )
{
e.Row.BackColor = System.Drawing.Color.Red;
}
else if (e.Row.Cells[14].Text == "ETOPS - Working")
{
e.Row.BackColor = System.Drawing.Color.Yello w;
}
else if (e.Row.Cells[14].Text == "AOG - R/T")
{
e.Row.BackColor = System.Drawing.Color.Tomat o;
}
else if (e.Row.Cells[14].Text == "High Priority")
{
e.Row.BackColor = System.Drawing.Color.Light SkyBlue ;
}
else if (e.Row.Cells[14].Text == "SOS - Working")
{
e.Row.BackColor = System.Drawing.Color.Orang e;
}
else if (e.Row.Cells[14].Text == "Working Spare")
{
e.Row.BackColor = System.Drawing.Color.Aquam arine;
}
else if (e.Row.Cells[14].Text == "AOG - Vendor")
{
e.Row.BackColor = System.Drawing.Color.Orang e;
}
else if (e.Row.Cells[14].Text == "AOG-Sched/Work Required")
{
e.Row.BackColor = System.Drawing.Color.Crims on;
}
else if (e.Row.Cells[14].Text == "AOG-Sched/Work Elective")
{
e.Row.BackColor = System.Drawing.Color.Coral ;
}
else if (e.Row.Cells[14].Text == "ETOPS Fly Day")
{
e.Row.BackColor = System.Drawing.Color.Fuchs ia;
}
else if (e.Row.Cells[14].Text == "Ready Spare")
{
e.Row.BackColor = System.Drawing.Color.Lime;
}
else if (e.Row.Cells[14].Text == "Ready Spare - A/C Hooked - WU-cw")
{
e.Row.BackColor = System.Drawing.Color.Lime;
}
else if (e.Row.Cells[14].Text == "Ready Spare - Needs WU ck")
{
e.Row.BackColor = System.Drawing.Color.Lime;
}
else if (e.Row.Cells[14].Text == "Ready Spare - A/C Hooked - Needs WU")
{
e.Row.BackColor = System.Drawing.Color.Lime;
}
else if (e.Row.Cells[14].Text == "Status Ready Spare - Needs WU-ck")
{
e.Row.BackColor = System.Drawing.Color.Lime;
}
else if (e.Row.Cells[14].Text == "High Priority")
{
e.Row.ForeColor = Color.Red;
}
protected void GridView1_RowDataBound(obj
{
if (e.Row.RowType == DataControlRowType.DataRow
if (e.Row.Cells[14].Text == "AOG" || e.Row.Cells[14].Equals(DBN
{
e.Row.BackColor = System.Drawing.Color.Red;
}
else if (e.Row.Cells[14].Text == "ETOPS - Working")
{
e.Row.BackColor = System.Drawing.Color.Yello
}
else if (e.Row.Cells[14].Text == "AOG - R/T")
{
e.Row.BackColor = System.Drawing.Color.Tomat
}
else if (e.Row.Cells[14].Text == "High Priority")
{
e.Row.BackColor = System.Drawing.Color.Light
}
else if (e.Row.Cells[14].Text == "SOS - Working")
{
e.Row.BackColor = System.Drawing.Color.Orang
}
else if (e.Row.Cells[14].Text == "Working Spare")
{
e.Row.BackColor = System.Drawing.Color.Aquam
}
else if (e.Row.Cells[14].Text == "AOG - Vendor")
{
e.Row.BackColor = System.Drawing.Color.Orang
}
else if (e.Row.Cells[14].Text == "AOG-Sched/Work Required")
{
e.Row.BackColor = System.Drawing.Color.Crims
}
else if (e.Row.Cells[14].Text == "AOG-Sched/Work Elective")
{
e.Row.BackColor = System.Drawing.Color.Coral
}
else if (e.Row.Cells[14].Text == "ETOPS Fly Day")
{
e.Row.BackColor = System.Drawing.Color.Fuchs
}
else if (e.Row.Cells[14].Text == "Ready Spare")
{
e.Row.BackColor = System.Drawing.Color.Lime;
}
else if (e.Row.Cells[14].Text == "Ready Spare - A/C Hooked - WU-cw")
{
e.Row.BackColor = System.Drawing.Color.Lime;
}
else if (e.Row.Cells[14].Text == "Ready Spare - Needs WU ck")
{
e.Row.BackColor = System.Drawing.Color.Lime;
}
else if (e.Row.Cells[14].Text == "Ready Spare - A/C Hooked - Needs WU")
{
e.Row.BackColor = System.Drawing.Color.Lime;
}
else if (e.Row.Cells[14].Text == "Status Ready Spare - Needs WU-ck")
{
e.Row.BackColor = System.Drawing.Color.Lime;
}
else if (e.Row.Cells[14].Text == "High Priority")
{
e.Row.ForeColor = Color.Red;
}
ASKER
Used other option listed above, without "else if" and used "if" works great. I would also like to change this to bold when the condition is met. Any ideas on that?
eRows[rowNr].Cells[14].For