469,626 Members | 1,062 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,626 developers. It's quick & easy.

Setting BackColor of GridView cell dynamically

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?

*** Sent via Developersdex http://www.developersdex.com ***
May 30 '06 #1
0 1623

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Rob Meade | last post: by
reply views Thread by Sourav Dutta Gupta | last post: by
4 posts views Thread by Ken Wigle | last post: by
8 posts views Thread by Jeff | last post: by
1 post views Thread by savajx1 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.