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.

5 votesVote for this answer Unmark Correct answer

Recent Answers

Johansen Jones answered on July 17, 2018 13:36

Their functionality is very similar to that of templates used by standard ASP.NET list controls such as the Repeater, which can be defined within the tags of a control through various ItemTemplate properties. The main difference is that our transformations are stored separately in the database and can easily be used repeatedly. They are assigned to web parts or controls through the appropriate TransformationName properties. MYBKExperience

0 votesVote for this answer Mark as a Correct answer

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