Solved

VB ASP.NET: Block of code ONLY if odd

Posted on 2011-09-12
4
252 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
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…

744 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

10 Experts available now in Live!

Get 1:1 Help Now