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: <yes/no>, <no/no>, <yes/yes>, <no/yes>.
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 <yes/no> completely either green or red.
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:
<asp:Label runat="server" Text='<%# FormatSalesOPDName(DataBinder.Eval(Container, "DataItem.ORD_StatusUSASales"), DataBinder.Eval(Container, "DataItem.ORD_StatusUSAOPD")) %>' > </asp:Label>
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; }