Translation of C# to VB in HTML

Posted on 2010-01-08
Last Modified: 2012-05-08
I'm working on implementing the following:
After a few stops and starts I am finally getting somewhere converting this to VB and to my particular scenario.
However, I can't seem to get past the following code snippet in the section marked "The Details":

         <tr class='<%# (Container.ItemIndex%2==0) ? "row" : "altrow" %>'>
             <td class="rownum">
                <%# Container.ItemIndex+1 %>

Can someone please translate this for me correctly?
I've tried the following:

        <tr class='<%# If ((Container.ItemIndex Mod 2)) = 0  THEN "row"  ELSE "altrow" %>'>
            <td class="rownum"><%#(Container.ItemIndex + 1)%></td>

but I continue to get the error message:
First operand in a binary 'If' expression must be nullable or a reference type.
I know it's got to be something simple I missing in converting things, but I've been staring at this since before the holiday break and, now that we're back, I'm going braindead.

oh, and I did download his project and verified that, yes, his code works as explained. So there's definitely something "Lost in Translation".

Thanks in advance!
Question by:bmickey
    LVL 25

    Accepted Solution

    <%# Iif((Container.ItemIndex Mod 2 = 0), "row", "altrow") %>

    Author Closing Comment

    I believe you meant 'if' and not 'lif'?
    That works though!
    Ugh! Can't believe it was that simple!
    LVL 25

    Expert Comment

    by:Luis Pérez
    In fact, it's the "IIF" vb function, not IF operand. Glad to help you.

    Author Comment

    oh -- Okay.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    It’s quite interesting for me as I worked with Excel using for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
    The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (…
    This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    754 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

    21 Experts available now in Live!

    Get 1:1 Help Now