Cell/Font Color in DataGrid.
I am using C#.NET, Visual Web Developer 2005 and SQL Server 2000.
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: <yes/no>, <no/no>, <yes/yes>, <no/yes>, <yes/cncld> , <no/cncld>.
This column can have one of these combination in the datagrid column. Now, I want to display all "yes" in green and all "no" in red and all "cncld" in black. so, essentially I want more than one color in my cell. I know that cell.Forecolor property can be applied to the entire cell making <yes/no> completely either green or red. But my task is applying more than one color in one cell.
Is there any way we can do this? I am able to capture the text "yes" , "no" and "cncld" 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:
<asp:Label runat="server" Text='<%# FormatSalesOPDName(DataBinder.Eval(Container, "DataItem.ORD_StatusUSASales"), DataBinder.Eval(Container, "DataItem.ORD_StatusUSAOPD")) %>' >
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;