I want to change a color of a special word NOT all words of a gridview Cell . here is event and codes:
protected void gvContents_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.Cells[3].Text.Contains("Special"))
{
//set The "Special" word only forecolor to red
}
else if (e.Row.Cells[3].Text == "Perishable")
{
//set The "Perishable" word only forecolor to blue
}
else if (e.Row.Cells[3].Text == "Danger")
{
//set The "Danger" word only forecolor to yellow
}
}
}
and Cell text might be like here :"Radioactive : Danger" or this : "Human Body : Special ,Perishable " what should I do?
Pravesh Singh
23-Jan-2014In the CellFormatting event handler, add the below code