New to .NET - If Then Else condition against database results

Discussion in 'ASP .Net' started by Troy Stanley - CyberWarehouse.com, Aug 14, 2003.

  1. How does one evaluate if a field is null to display it in the datalist or
    repeater? I have tried a number of different things...

    Would anyone know how to do this?

    <asp:Repeater id="customers" runat="server"><HeaderTemplate>
    <table border="1" width="100%">

    </HeaderTemplate><ItemTemplate>
    <%IF #Container.DataItem("detProcessor") <> "" Then
    <tr><td><%#Container.DataItem("detProcessor")%></td></tr>
    End IF %>

    </ItemTemplate><FooterTemplate>
    </table>
    </FooterTemplate></asp:Repeater>

    I have a feeling that I can't run arguments against the container within the
    repeater.


    --
    Thanks!

    Troy Stanley
    devteam a.t cyberwarehouse.com
    www.CyberWarehouse.com
     
    Troy Stanley - CyberWarehouse.com, Aug 14, 2003
    #1
    1. Advertising

  2. I'm reasonably new too, but I think an acceptable solution would be to
    pass the databound item to a function, which would sit in your
    code-behind and return your formatted data if it weren't null.

    <%# FormatData(DataBinder.Eval(Container.DataItem, "detProcessor")) %>

    in your repeater...

    then in your code-behind...

    protected string FormatData(string data)
    {
    string result = "No data";
    if (!data.Equals(string.Empty))
    result = data.ToString();
    return result;
    }

    I think that would work...?



    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    Brandon Wagner, Aug 14, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. -
    Replies:
    12
    Views:
    717
    Remon van Vliet
    Jun 15, 2005
  2. gk
    Replies:
    7
    Views:
    33,858
    sathya_k_83
    Nov 20, 2007
  3. Replies:
    0
    Views:
    339
  4. Bill W.
    Replies:
    13
    Views:
    318
    Phillip Gawlowski
    May 9, 2011
  5. Replies:
    15
    Views:
    248
Loading...

Share This Page