Print Page | Close Window

Needs Help with IIf Statement

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: ASP.NET Discussion
Forum Description: Discussion and chat on ASP.NET related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=13562
Printed Date: 29 March 2026 at 12:33pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Needs Help with IIf Statement
Posted By: Misty
Subject: Needs Help with IIf Statement
Date Posted: 29 January 2005 at 3:28pm
I need help with an IIF statement in ASP.Net.
 
The line of code:  <%# IIF(Container.DataItem("PublicEmail") = False,"<p><font face=sans-serif color=#330099><b>Name:</FONT></b>&nbsp;<a href='mailto:" & Container.DataItem("Email") & "'>" & Container.DataItem("Name") & "</a>", "") %> works fine.
 
However, I would like to be able to display the name without being hyperlinked to an email address.
 
I tried the following line of code: <%# IIF(Container.DataItem("PublicEmail") = False,"<p><font face=sans-serif color=#330099>Name:</FONT>&nbsp;<FONT face=sans-serif>& Container.DataItem("Name") & "</font>", "")%>
 
This is the line of code I need help with. It's a problem with the syntax. Please look at the red part.
 
Here's a copy of the error message that I got on that line:
Compiler Error Message: BC30455: Argument not specified for parameter 'FalsePart' of 'Public Function IIf(Expression As Boolean, TruePart As Object, FalsePart As Object) As Object'.

Source Error:

Line 160:            <tr valign="top"> 
Line 161:         <td> <%# IIF(Container.DataItem("PublicEmail") = True,"<p><font face=sans-serif color=#330099><b>Name:</FONT></b>&nbsp;<a href='mailto:" & Container.DataItem("Email") & "'>" & Container.DataItem("Name") & "</a>", "") %>
Line 162:             <%# IIF(Container.DataItem("PublicEmail") = False,"<p><font face=sans-serif color=#330099>Name:</FONT>&nbsp;<FONT face=sans-serif>& Container.DataItem("Name") & "</font>", "")%>



Replies:
Posted By: Mart
Date Posted: 29 January 2005 at 3:49pm
<%# IIF(Container.DataItem("PublicEmail") = False,"<p><font face=sans-serif color=#330099>Name:</FONT>&nbsp;<FONT face=sans-serif>" & Container.DataItem("Name") & "</font>", "")%>


Posted By: Misty
Date Posted: 29 January 2005 at 8:41pm
Mart,
 
Thanks! I just missed one ". That's why I got the error message.
 
I have a question. Does anyone know if you can use else statements in ASP.Net or not? I have never seen else statements in ASP.Net before. I often use else statements in ASP.


Posted By: Mart
Date Posted: 30 January 2005 at 3:43am
Yes, of course you can, you can do

If [Boolean] Then
'true condition
Else
'false condition
End If



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net