[RESOLVED] What can you do when a repeater has an empty field?
I am trying to take advantage of the repeater control. I was wondering how I could go about seeing if the field was going to be empty because the database might have had no or null data in it for a particular field.
Code:
<asp:Repeater ID="RepeaterRelatives" runat="server">
<ItemTemplate>
<strong><%#Eval("Relation")%></strong> : <%#Eval("RelativeFN")%> <%#Eval("RelativeLN")%><br />
Birth Place: <%#Eval("RelativeBP")%> | e-Mail: <%#Eval("RelativeEmail")%> |
Instant Messenger Handle: <%#Eval("RelativeIM")%>
</ItemTemplate>
<SeparatorTemplate>
<hr />
</SeparatorTemplate>
</asp:Repeater>
So let's say <%#Eval("RelativeIM")%> didn't have any data. Well, my page is going to still print out the text Instant Messenger Handle: but there will be a space and then the next field will print out, for examples sake.
So I was wondering how I could go about saying ok, if <%#Eval("RelativeIM")%> is going to be null or empty, don't print out Instant Messenger Handle:
I'd appreciate comments or ideas. THank you so much in advance.
Re: What can you do when a repeater has an empty field?
Use a label instead of direct text and then you should do something like this:
Code:
if ( ( ( Label )Repeater1.FindControl("Label1") ).Text == string.Empty )
Re: What can you do when a repeater has an empty field?
Thank you for showing me this.