I have a number of colours in a database linked to different conditions, and this data is displayed in a gridview. I want to set the BackColor of a gridview cell dependent upon this value, for example FF0000 etc. The code I have used gives me the error 'specified cast is not valid' :
<asp:TemplateField HeaderText="Forecast Type" SortExpression="ForecastDescription">
<ItemTemplate>
<asp:Label ID="lblForecastType" Text='<%# Eval("ForecastDescription") %>' BackColor='<%# Eval("ForecastColor") %>' runat="server"></asp:Label>
</ItemTemplate>
<ItemStyle Height="24px" Width="50px" />
</asp:TemplateField>
Any ideas how to do this?
<asp:TemplateField HeaderText="Forecast Type" SortExpression="ForecastDescription">
<ItemTemplate>
<asp:Label ID="lblForecastType" Text='<%# Eval("ForecastDescription") %>' BackColor='<%# Eval("ForecastColor") %>' runat="server"></asp:Label>
</ItemTemplate>
<ItemStyle Height="24px" Width="50px" />
</asp:TemplateField>
Any ideas how to do this?