Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VB ASP.NET: Block of code ONLY if odd

Posted on 2011-09-12
4
Medium Priority
?
268 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 1000 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 1000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

885 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