Hi,
Is this function is correct if not please guide me-
<%#Eval("Doc_IsMember").ToString() == "1" ?
Eval("Doc_Phone"):"
Eval("Doc_Phone"):"
View Contact Detail
"%> Eval('Doc_Phone')
second Eval('DOC_Phone') is not working.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Manish Kumar ChoudharyRank #339 · 7.4K reputationPosted Feb 10, 2015, 9:22 PM EST
<%#Eval("Doc_IsMember").ToString() == "1" ?
Eval("Doc_Phone"): Server.HtmlEncode("
Manish Kumar ChoudharyRank #339 · 7.4K reputationPosted Feb 10, 2015, 9:23 PM EST
Posted Feb 10, 2015, 9:31 PM EST
In First solution it giving me the error as : New Line Constant
If I write that whole in one line than it is showing me whole dive as normal html code.
Is there another solution?
Manish Kumar ChoudharyRank #339 · 7.4K reputationPosted Feb 10, 2015, 9:33 PM EST
Posted Feb 10, 2015, 9:41 PM EST
Manish Kumar ChoudharyRank #339 · 7.4K reputationPosted Feb 10, 2015, 9:49 PM EST
in place of Server.HtmlEncode()keyurRank #5,481 · 298 reputationPosted Feb 10, 2015, 9:58 PM EST
You can make function too like below
Text='<%# myFormat(Eval("UnitPrice")) %>'>
Code Behind
protected string myFormat(object strArg)
{
decimal val = Convert.ToDecimal(strArg) ;
if (val == 0 )
{
return "";
}
else
{
return string.Format("{0:C}", strArg);
}
}
Hope this helps
Posted Feb 10, 2015, 10:01 PM EST
Type of conditional expression cannot be determined because there is no implicit conversion between 'object' and 'void'