Solved

VB ASP.NET: Block of code ONLY if odd

Posted on 2011-09-12
4
263 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
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 (http://www.ecb.europa.eu/stats/exch…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

622 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