I have a ListView that has two columns, one for a zone name and then a corresponding OK/NOK in the second column.
I wish to format the second column based on whether it contains OK or NOK.
I could do this quite easily with a GridView by using something similar to the following, I may be wrong, but from what I can see a ListView doesn’t have the same option.
protected void grdZoneStatus_OnRowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.Cells[1].Text == "NOK")
{
e.Row.Cells[1].ForeColor = Color.Red;
}
}
So basically, how should I go about formatting a cell based on its contents within a ListView?
Assuming you have a ListView called lvTest which two columns of which the second one is the relevant, this:
should do the trick.