Results 1 to 3 of 3

Thread: [RESOLVED] What can you do when a repeater has an empty field?

  1. #1

    Thread Starter
    Hyperactive Member gjon's Avatar
    Join Date
    Nov 2004
    Location
    Inescapable Void
    Posts
    442

    Resolved [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.

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    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

  3. #3

    Thread Starter
    Hyperactive Member gjon's Avatar
    Join Date
    Nov 2004
    Location
    Inescapable Void
    Posts
    442

    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
  •  



Click Here to Expand Forum to Full Width