datagrid template column forecolor

D

dodgeyb

This template column should show forecolor as red when the bit
datafield 'SIG' is true.


<asp:TemplateColumn HeaderText="Area">
<ItemStyle HorizontalAlign="left"></ItemStyle>
<ItemTemplate>
<asp:HyperLink runat="server" ForeColor='<%#
IIf(DataBinder.Eval(Container.DataItem, "SIG"), "red","black") %>'
Text='<%# DataBinder.Eval(Container, "DataItem.AREA_NAME") %>'
ID="Hyperlink1">
</asp:HyperLink>
</ItemTemplate>
</asp:TemplateColumn>

I've checked the data - no nulls, error msg is : specified cast is not
valid. Definately the forecolor since if I remove it it runs fine.
Thanks for all help !
 
E

Eliyahu Goldin

You are limited in data binding expressions. You can bind to any public
field or property on the containing page or on the server control's
immediate naming container available as Container.DataItem. IIf statement is
neither of them.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
 
D

dodgeyb

I'm always using the iif function in datagrid template cols ?!, and
this is the first prob I've encoutered. How do you do conditional
formatting ?
Thanks & regards
Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top