• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 519
  • Last Modified:

Translation of C# to VB in HTML

I'm working on implementing the following:
http://mosesofegypt.net/page/Building-on-demand-MasterDetail-grouping-Grid-with-GridView-and-ASPNET-AJAX-toolkit-CollapsiblePanelExtender.aspx
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":

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

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

<ItemTemplate>
        <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!
0
bmickey
Asked:
bmickey
  • 2
  • 2
1 Solution
 
Luis PérezSoftware Architect in .NetCommented:
<%# Iif((Container.ItemIndex Mod 2 = 0), "row", "altrow") %>
0
 
bmickeyAuthor Commented:
Thanks!
I believe you meant 'if' and not 'lif'?
That works though!
Ugh! Can't believe it was that simple!
0
 
Luis PérezSoftware Architect in .NetCommented:
In fact, it's the "IIF" vb function, not IF operand. Glad to help you.
0
 
bmickeyAuthor Commented:
oh -- Okay.
Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now