How to use "If Condition" with <%#Eval("")%> Function


Wednesday, August 26, 2009

Sometimes you might need to use if condition in Eval function,

But if condition is not support by Eval
Not able to use if condition with <%#Eval("sPhone")%>

see this code


-----------IN HTMl code---------------

<%#ReplaceField(Eval("sWebSite").ToString())%>


-----------IN code behind code--------
public string ReplaceField(string stat)
{
string newValue = "";
if (stat == "N/A")
{
newValue=""+stat+"";
}
else
{
newValue = "" + stat + "";
}

return newValue;
}

No comments :