D
D. Shane Fowlkes
I'm using ASP.NET (VB) and I'm pretty new to .NET and using Templates.
I have a SqlDataReader which is bound to a Repeater. The Repeater contains
a table and for each record, it'll write a table. Easy stuff so far. My
table contains typical Address and Phone numbers data. What I'd like to do
is check to see if "Address2" (field) is empty and/or null. If so then skip
the line all together, but if it does contain something, write:
<%# Container.DataItem("Address2") %><br />
Make sense? I'm trying to avoid having an empty line between Address2 and
City, State Zip. I've experimented with a "helper function" by sending
Address2 to a Function and have it send back nothing or literally the HTML
to complete this line. But again, if it's null, it errors. Hmmm. What to
do??
I would appreciate any pointers or advice.
<asp:Repeater ID="rptProviders" Runat="Server">
<ItemTemplate>
<table width="95%" border="0" align="center" cellpadding="5"
cellspacing="0" class="grid">
<tr>
<td class="colheader">(<% =intGlobalCounter %>) <%#
Container.DataItem("OrgName") %></td>
</tr>
<tr>
<td>
<p align="center"><img src="../assets/providers/<%#
Container.DataItem("Photo") %>" class="imgborder" border="0" /></p>
<p><%# Container.DataItem("ProfileDescription") %></p>
<p>Serving: Area 1, Area 2, Area 3</p>
<p><%# Container.DataItem("Address") %><br />
<%# Container.DataItem("Address2") %><br />
<%# Container.DataItem("City") %>, <%# Container.DataItem("State") %> <%#
Container.DataItem("Zip") %><br />
<%# Container.DataItem("Phone") %><br />
<%# Container.DataItem("Fax") %><br />
<a href="mailto:<%# Container.DataItem("ContactEmail") %>"><%#
Container.DataItem("ContactEmail") %></a><br />
<a href="<%# Container.DataItem("WebSite") %>" target="_blank"><%#
Container.DataItem("WebSite") %></a></p></td>
</tr>
</table>
<% intGlobalCounter = intGlobalCounter + 1 %>
</ItemTemplate>
</asp:Repeater>
I have a SqlDataReader which is bound to a Repeater. The Repeater contains
a table and for each record, it'll write a table. Easy stuff so far. My
table contains typical Address and Phone numbers data. What I'd like to do
is check to see if "Address2" (field) is empty and/or null. If so then skip
the line all together, but if it does contain something, write:
<%# Container.DataItem("Address2") %><br />
Make sense? I'm trying to avoid having an empty line between Address2 and
City, State Zip. I've experimented with a "helper function" by sending
Address2 to a Function and have it send back nothing or literally the HTML
to complete this line. But again, if it's null, it errors. Hmmm. What to
do??
I would appreciate any pointers or advice.
<asp:Repeater ID="rptProviders" Runat="Server">
<ItemTemplate>
<table width="95%" border="0" align="center" cellpadding="5"
cellspacing="0" class="grid">
<tr>
<td class="colheader">(<% =intGlobalCounter %>) <%#
Container.DataItem("OrgName") %></td>
</tr>
<tr>
<td>
<p align="center"><img src="../assets/providers/<%#
Container.DataItem("Photo") %>" class="imgborder" border="0" /></p>
<p><%# Container.DataItem("ProfileDescription") %></p>
<p>Serving: Area 1, Area 2, Area 3</p>
<p><%# Container.DataItem("Address") %><br />
<%# Container.DataItem("Address2") %><br />
<%# Container.DataItem("City") %>, <%# Container.DataItem("State") %> <%#
Container.DataItem("Zip") %><br />
<%# Container.DataItem("Phone") %><br />
<%# Container.DataItem("Fax") %><br />
<a href="mailto:<%# Container.DataItem("ContactEmail") %>"><%#
Container.DataItem("ContactEmail") %></a><br />
<a href="<%# Container.DataItem("WebSite") %>" target="_blank"><%#
Container.DataItem("WebSite") %></a></p></td>
</tr>
</table>
<% intGlobalCounter = intGlobalCounter + 1 %>
</ItemTemplate>
</asp:Repeater>