I want to change the forecolor of the row which row contains a specific word "MG". I used the below code but it is not working on the web application.
What I have tried:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.Cells[0].Text.ToString().Contains("MG"))
{
e.Row.ForeColor = System.Drawing.Color.Blue;
e.Row.Style["text-align"] = "Left";
}
else
{
e.Row.ForeColor = System.Drawing.Color.Black;
e.Row.Style["text-align"] = "Left";
}
}
}