Help!! i'm stuck in a big way

Discussion in 'ASP .Net' started by Chris, May 28, 2004.

  1. Chris

    Chris Guest

    Hey - sorry for the double post - but i'm really stuck and needing to fix
    this quicksmart.

    Okay using DataBinder.Eval in a repeater.

    My question is this - if the Container.Item value is empy, eg myDownloadFile
    is empty,
    how can i display different output than if it was populated.

    # pretend code
    <% if DataBinder.Eval(Container.Item, "myDownloadFile) == String.Empty) { %>
    Now download file is available
    <% } else { %>
    Click here to download <%# DataBinder.Eval(Container.Item, "myDownloadFile")
    %>
    <% } %>

    How can i achieve this ? i believe i could use a terniary but thats well
    nasty :)

    <%# DataBinder.Eval(Container.Item, 'Example') != String.Empty ? "download
    bleh" : "no download" %>

    You help is must appreciated :)
    Thanks
    Chris
     
    Chris, May 28, 2004
    #1
    1. Advertising

  2. Chris,
    I would solve this problem by wrapping the DataBinder.Eval call in a
    method that returns a string. Define this method in your page code.
    <%#MyMethod(DataBinder.Eval(Container.Item, "myDownloadFile"))%>

    public string MyMethod(string myVar){
    if(myVar == string.Empty){
    return "No download file is available.";
    }else{
    return "Click here to download . . .";
    }
    }

    Best Regards,
    Jeffrey Palermo

    "Chris" <> wrote in message
    news:...
    > Hey - sorry for the double post - but i'm really stuck and needing to fix
    > this quicksmart.
    >
    > Okay using DataBinder.Eval in a repeater.
    >
    > My question is this - if the Container.Item value is empy, eg

    myDownloadFile
    > is empty,
    > how can i display different output than if it was populated.
    >
    > # pretend code
    > <% if DataBinder.Eval(Container.Item, "myDownloadFile) == String.Empty)

    { %>
    > Now download file is available
    > <% } else { %>
    > Click here to download <%# DataBinder.Eval(Container.Item,

    "myDownloadFile")
    > %>
    > <% } %>
    >
    > How can i achieve this ? i believe i could use a terniary but thats well
    > nasty :)
    >
    > <%# DataBinder.Eval(Container.Item, 'Example') != String.Empty ? "download
    > bleh" : "no download" %>
    >
    > You help is must appreciated :)
    > Thanks
    > Chris
    >
    >
     
    Jeffrey Palermo [MCP], May 28, 2004
    #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:
    11
    Views:
    754
    Roedy Green
    Sep 18, 2005
  2. Shaguf
    Replies:
    0
    Views:
    560
    Shaguf
    Dec 24, 2008
  3. Shaguf
    Replies:
    0
    Views:
    506
    Shaguf
    Dec 26, 2008
  4. Shaguf
    Replies:
    0
    Views:
    277
    Shaguf
    Dec 26, 2008
  5. Shaguf
    Replies:
    0
    Views:
    257
    Shaguf
    Dec 24, 2008
Loading...

Share This Page