Re: Inline Code Error
ASP.NET
2
Posts
2
Posters
0
Views
1
Watching
-
Hi Friends, I am using a condition in aspx page(Inline C# code). Can anyone tell me whats the problem with the following code:
<%# if(Convert.ToString(DataBinder.Eval(Container.DataItem,"EventTo")) != ""){%>Hello<%}%>
Thanks for your help.
Sushant Duggal.
-
Hi Friends, I am using a condition in aspx page(Inline C# code). Can anyone tell me whats the problem with the following code:
<%# if(Convert.ToString(DataBinder.Eval(Container.DataItem,"EventTo")) != ""){%>Hello<%}%>
Thanks for your help.
Sushant Duggal.
Try converting this to a function call. Something like:
string MyFunction(object o)
{
string eventTo = Convert.ToString(o);
if eventTo != ""
return "Hello"
else
return eventTo
}Then your databinding expression can be:
<%# MyFunction(DataBinder.Eval(Container.DataItem, "EventTo")) %>