Sherry Collins asked on May 27, 2015 22:12

In my transformation I need to return the number of comments. I can't copy the line because it strips out all the HTML.

Anyway the line

GetDocumentUrl() #comments"><%# BlogFunctions.GetBlogCommentsCount(Eval("DocumentID"), Eval("NodeAliasPath")) %> comments

This is all wrapped in an anchor tag/div tag.

From this I get the number of comments.

If GetBlogcommentCount returns 0 then they want to print Add A Comment instead of 0 comments.

Is there a way I can do this

Correct Answer

Petar Kozjak answered on May 28, 2015 10:13


to display different message on 0 you can use ifCompare function: <%# IfCompare(1, 2, "The values are different", "The values are equal") %>

It would look like this: <%# IfCompare(BlogFunctions.GetBlogCommentsCount(Eval("DocumentID"), Eval("NodeAliasPath")), "0", BlogFunctions.GetBlogCommentsCount(Eval("DocumentID"), Eval("NodeAliasPath")) + " comments", "Add comments") %>

Replace string "Add comments" with your code for reaching comment section.

Hope this helps.

4 votesVote for this answer Unmark Correct answer

   Please, sign in to be able to submit a new answer.