1

I am trying to put HTML in a gridview cell for example:

<span class="badge badge-info">Processing</span>

It makes the Processing Text highlight blue, and I am trying to change the color to green depending on a value. How would I do this? I know using a Literal could work, but I do not know how to do that inside a Gridview.

Billy Hen
  • 13
  • 8
  • http://stackoverflow.com/questions/18539151/how-to-display-text-based-on-the-column-value-from-database – Jeremy May 06 '15 at 15:50
  • http://stackoverflow.com/questions/5048762/change-gridview-row-color-based-on-condition-in-c-sharp – Jeremy May 06 '15 at 15:51
  • That is C# and I am trying to pass HTML through – Billy Hen May 06 '15 at 15:58
  • how are you populating the grid? back end code? if so, handle the events shown in the samples. regardless of language, the technique is the same. – Jeremy May 06 '15 at 16:12

1 Answers1

0

well it`s some how ambiguous to know what you want but hope this will help

int place=0; //the cell to add the literal in
foreach (GridViewRow row in dataGridView1.Rows)
{           
    if (value)
    row.Cells[place].Controls.Add(new LiteralControl("<span class=\"toto\"> blah</span>"));
}
Modar Na
  • 49
  • 4