DataBinder.Eval(Container.Item, "myDownloadFile") Question

C

Chris

Hey

Okay using DataBinder.Eval in a repeater.

My question is this - if the value is empy, eg the 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
 
G

Guest

Hi, Chri

Databinding on aspx page cannot contain complicated logic
You can achieve that in the Repeater's ItemDataBound Event
void R1_ItemDataBound(Object Sender, RepeaterItemEventArgs e)
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
if (e.Item.DataItem("myDownloadFile") == String.Empty)
((Label)e.Item.FindControl("myDownloadFile")).Text= "No download file available"


}
 

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

Top