Help!! i'm stuck in a big way

C

Chris

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
 
J

Jeffrey Palermo [MCP]

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top