468,140 Members | 1,456 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,140 developers. It's quick & easy.

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

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
Nov 18 '05 #1
1 1587
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"
}

Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.