Solved inline nested ternary

Posted on 2012-08-29
Last Modified: 2012-08-30
Hi everybody,

is it possible to nest a ternary inside an inline command?

<asp:TemplateField HeaderText="Speciality" SortExpression="DryLabTime">
                            <%#Eval("DryLabTime") == "Session1" ? "A" : 
                               (Eval("DryLabTime") == "Session2" ? "B" :
                               (Eval("DryLabTime") == "Session3" ? "C" :
                                (Eval("DryLabTime") == "Session4" ? "D" :
                                (Eval("DryLabTime") == "Session5" ? "E" :

Open in new window

Thanks for your help
Question by:arthrex
    1 Comment
    LVL 25

    Accepted Solution

    Yes you can . I think you might need one small change, "ToString()".

    Eval("DryLabTime") .ToString() instead of just Eval("DryLabTime")

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
    Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now