Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / October 2007

Tip: Looking for answers? Try searching our database.

datagrid template column forecolor

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
dodgeyb - 06 Oct 2007 21:31 GMT
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 - 07 Oct 2007 09:56 GMT
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.

Signature

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

> This template column should show forecolor as red when the bit
> datafield 'SIG' is true.
[quoted text clipped - 13 lines]
> valid. Definately the forecolor since if I remove it it runs fine.
> Thanks for all help !
dodgeyb - 07 Oct 2007 23:36 GMT
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 - 08 Oct 2007 09:35 GMT
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.

Signature

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

> 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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.