PC Review


Reply
Thread Tools Rate Thread

datagrid template column forecolor

 
 
dodgeyb
Guest
Posts: n/a
 
      6th Oct 2007
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 !

 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      7th Oct 2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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 !
>



 
Reply With Quote
 
dodgeyb
Guest
Posts: n/a
 
      7th Oct 2007
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

 
Reply With Quote
 
Eliyahu Goldin
Guest
Posts: n/a
 
      8th Oct 2007
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
setting Column width of Template Column in Datagrid.. Charleees Microsoft ASP .NET 2 20th Jun 2006 01:52 PM
Alternating Item Style "ForeColor" not working in Template Column =?Utf-8?B?TWF4IFdlZWJsZXI=?= Microsoft ASP .NET 9 27th Oct 2005 07:06 PM
DataGrid loses view state if first column is a template column. Ken Varn Microsoft ASP .NET 1 19th Aug 2005 03:54 PM
Datagrid Column Forecolor Carl Tribble Microsoft VB .NET 5 10th Feb 2005 09:23 PM
DataGrid template column help!!! X-Men Microsoft ASP .NET 1 8th Jun 2004 03:18 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:41 AM.