Hi, I am using Datagrid, SqlDataAdapter and Dataset for displaying data. One of the resultant column of the Datagrid is composed of concatenation of 2 columns in my database and is displayed like:
This column can have one of these 4 texts in the datagrid column. Now, I want to display all "yes" in green and all "no" in red. so, essentially I want more than one color in my cell. cell.Forecolor property can be applied to the entire cell making
Is there any way we can do this? I am able to capture the text "yes" and "no" as a string, but how do i then apply color? Should this be done in html file or the code behind file?
I am concatenating the two columns in html as:
In code-behind:
protected string FormatSalesOPDName(object ORD_StatusUSASales, object ORD_StatusUSAOPD)
{
// Combine the names to get the Sales/OPD First format.
return (string)ORD_StatusUSASales + "/" + (string)ORD_StatusUSAOPD;
}
nikshuklaPosted Dec 4, 2006, 3:58 PM
i.e.
If e.Item.ItemType = ListItemType.Item OR e.Item.ItemType == ListItemType.AlternatingItem then
Dim lbl as Label = e.Item.Cell(1).FindControl("YourLabelControl")
Dim str as String = lbl.Text
Select Case str
Case "YES/YES"
e.Item.Cells(1).BackColor = Color.Green
Case "NO/NO"e.Item.Cells(1).BackColor = Color.Red
End SelectEnd If
Hope this helps.
Regards,