Solved

VB ASP.NET: Block of code ONLY if odd

Posted on 2011-09-12
4
253 Views
Last Modified: 2012-05-12
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
Comment
Question by:hankknight
  • 2
4 Comments
 
LVL 5

Expert Comment

by:Rainverse
ID: 36524809
Can you explain a little better? You only want the link to display for odd numbers??
0
 
LVL 16

Author Comment

by:hankknight
ID: 36525268
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
 
LVL 5

Accepted Solution

by:
Rainverse earned 250 total points
ID: 36525377
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
 
LVL 83

Assisted Solution

by:CodeCruiser
CodeCruiser earned 250 total points
ID: 36526220
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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net 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 …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
A short film showing how OnPage and Connectwise integration works.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

932 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