hankknight
asked on
ASP.NET/VB: Only if not blank
I use this VB ASP.NET code to display the publication title and content:
I only want the first line to be send if the publication title is NOT blank. This does NOT work:
<p>
<strong><%#Container.DataItem("PublicationTitle")%></strong><br />
<%#Container.DataItem("Content")%>
</p>
I only want the first line to be send if the publication title is NOT blank. This does NOT work:
<p>
[IF #Container.DataItem("PublicationTitle")]<strong><%#Container.DataItem("PublicationTitle")%></strong><br />[END-IF]
<%#Container.DataItem("Content")%>
</p>
ASKER
That code gives me an error:
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30451: Name 'Container' is not declared.
Compiler Error Message: BC30451: Name 'Container' is not declared.
Sorry, my bad, I was thinking something else...
<p>
<%# GetTitleText(Container.Dat aItem("Pub licationTi tle")) %>
<%#Container.DataItem("Con tent")%>
</p>
public function GetTitleText(title As Object) As String
If String.IsNullOrEmpty(title .ToString( )) Then
Return ""
Else
Return "<strong>" & title.ToString() & "</strong></br>"
End If
end function
<p>
<%# GetTitleText(Container.Dat
<%#Container.DataItem("Con
</p>
public function GetTitleText(title As Object) As String
If String.IsNullOrEmpty(title
Return ""
Else
Return "<strong>" & title.ToString() & "</strong></br>"
End If
end function
Hello, you have to use IIf(IsDBNull) function for that.
ASKER
I am still confused. What code do I need to put where?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<% If Not String.IsNullOrEmpty(Conta
Response.Write("<strong>" & Container.DataItem("Public
End If %>
<%#Container.DataItem("Con
</p>