I want to change the color of some special words NOT all words in a gridview cell. Here is the code:
protected void gvContents_RowDataBound(obj
Use a combination of span tags and CSS classes. First create the CSS classes in your aspx code:
then replace all occurences of Special
to Special
, Perishable
to Perishable
, and Danger
to Danger
:
protected void gvContents_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[3].Text = e.Row.Cells[3].Text.Replace("Special", "Special")
.Replace("Perishable", "Perishable")
.Replace("Danger", "Danger");
}
}