Conditionally write Template DataItem

D

D. Shane Fowlkes

This should be really simple. I've asked this a few times on various board
and have never received an answer. =(

I have a Template which is bound to rows of data. Whoopie. Some of my
items in the Template may not contain data and thus, they display as an
empty line on the page. How can I use a little logic and have the template
SKIP the item if it's Null or Empty?

For example:
<%# Container.DataItem("Address") %><br />
<%# Container.DataItem("Address2")%><br />
<%# Container.DataItem("City") %>, <%# Container.DataItem("State") %>, <%#
Container.DataItem("Zip") %><br />

"Address2" might be empty. If it is, how can I skip this line all together
so a blank line doesn't appear on the page?

I've tried various versions of IF and IsDbNull and have not had any luck.
This doesn't work but I'm looking for something that accomplishes the same
thing...
<%#
If Container.DataItem("Address2") <> "" Then
Container.DataItem("Address2") & "<br />"
End If
%>


Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,821
Latest member
AleidaSchi

Latest Threads

Top