|
-
Jun 23rd, 2007, 12:43 AM
#1
Thread Starter
Hyperactive Member
[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.
-
Jun 23rd, 2007, 06:36 AM
#2
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 )
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Jun 23rd, 2007, 01:38 PM
#3
Thread Starter
Hyperactive Member
Re: What can you do when a repeater has an empty field?
Thank you for showing me this.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|