Welcome Guest Search | Active Topics | Members | Log In | Register

datagrid template column forecolor Options · View
dodgeyb
Posted: Saturday, October 06, 2007 6:31:58 AM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 06/10/2007 06:31:58
Date: Sat, 06 Oct 2007 13:31:58 -0700

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 !

dodgeyb
Posted: Sunday, October 07, 2007 8:36:58 AM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 07/10/2007 08:36:58
Date: Sun, 07 Oct 2007 15:36:58 -0700

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

Eliyahu Goldin
Posted: Sunday, October 07, 2007 12:56:35 PM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 07/10/2007 12:56:35
Date: Sun, 7 Oct 2007 10:56:35 +0200

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


"dodgeyb" <chris@ctlsoft.com> wrote in message
news:1191702718.639595.267020@g4g2000hsf.googlegroups.com...
> 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 !
>


Eliyahu Goldin
Posted: Monday, October 08, 2007 12:35:04 PM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 08/10/2007 12:35:04
Date: Mon, 8 Oct 2007 10:35:04 +0200

Ok, I am not good with VB.

What is the type of the "SIG" field? Apparently, IIf expects the first
parameter to be boolean and DataBinder.Eval(Container.DataItem, "SIG")
doesn't not evaluate to a boolean.

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


"dodgeyb" <chris@ctlsoft.com> wrote in message
news:1191796618.169860.164770@y42g2000hsy.googlegroups.com...
> 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
>


Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

YAFPro Theme Created by Jaben Cargman (Tiny Gecko)
Powered by Yet Another Forum.net version 1.9.1.1 (NET v2.0) - 9/10/2007
Copyright © 2003-2006 Yet Another Forum.net. All rights reserved.
This page was generated in 0.052 seconds.