Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 272
  • Last Modified:

VB ASP.NET: Block of code ONLY if odd

How can I apply this:
<%# IIf ( Container.ItemIndex Mod 2 <> 0, "", "--- BLOCK OF CODE HERE ---")%>

Open in new window


To this?
<%#Container.DataItem("NAME")%>
&nbsp; / &nbsp; <a href="<%=Session("WSDownloadAsset") %>assetid=<%#Container.DataItem("Asset_ID")%>&dtype=assetdownload&size=0">Download</a>

Open in new window


I want the output from the code above ONLY to be displayed for odd items.
0
hankknight
Asked:
hankknight
  • 2
2 Solutions
 
RainverseCommented:
Can you explain a little better? You only want the link to display for odd numbers??
0
 
hankknightAuthor Commented:
Correct, I only want it to display every other item.

Actually, the reason for my question is that I want to learn how to include blocks of code inside an if statement.
0
 
RainverseCommented:
I normally only do code-behind, but I don't believe you can do what you're wanting to do.  Not in an in-line IIF, anyway.  The ampersands and quotes in the code are going to screw things up a bit.  I believe this, however, would work....

  <% If ( Container.ItemIndex Mod 2 <> 0 %>
       <%#Container.DataItem("NAME")%>&nbsp; / &nbsp; <a href="<%=Session("WSDownloadAsset") %>assetid=<%#Container.DataItem("Asset_ID")%>&dtype=assetdownload&size=0">Download</a>
  <% End If%>

Open in new window

0
 
CodeCruiserCommented:
I would use a container control such as a panel or a literal and then set its visible property using the IIF code block.
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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
Tackle projects and never again get stuck behind a technical roadblock.
Join Now