Count Item retrieved in repeater or in transformation

Novice User asked on May 25, 2018 00:37

I need to count item retrieved by the document helper and if there are no documents returned I want to show a message. My options are

  1. In transformation I am using {%DataItemCount%} but its not returnuing zero so that i can check it against an if condition like this {% if (DataItemCount < 1) {DataItemCount} #%}

  2. How do you know how many item count are there in a basic repeater so that i can check that at the back end of a web part

or is there any other way to know no documents are returned ?

Recent Answers


Brenden Kehren answered on May 25, 2018 01:30

If there are no items returned there will be no transformation rendered. Use the zero items message text property to display a message for zero rows.

1 votesVote for this answer Mark as a Correct answer

Peter Mogilnitski answered on May 25, 2018 01:50 (last edited on May 25, 2018 01:51)

Repeater has property No Data Behavior, so there is no need to check it. DataItemCount - gets the total number of data items in the current transformation container. If everything was done correctly you should get the correct total. You macro should work

1 votesVote for this answer Mark as a Correct answer

Novice User answered on May 25, 2018 19:39 (last edited on May 25, 2018 23:36)

Thank you Brenden Kehren and Peter Mogilnitski for your input. Is there a way that I can get a count ? I need to make controls visible / not visible based on if the count = 0. I am also using a uni pager control and this condition

if (myUniPager.DataSourceItemsCount == 0)

is also returning zero always no matter how many records are there in basic repeater. Am i missing some thing here ?

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on May 25, 2018 19:43

What's the structure of your template? Are you using one datasource for multiple webparts?

0 votesVote for this answer Mark as a Correct answer

Novice User answered on May 25, 2018 21:40

I have a web part using a document query for e.g

var List = DocumentHelper.GetDocuments("my.something").Path(myPath);

and then i am using basic repeater to data bind it along with uni pager. so basically its one data source for a web part.

0 votesVote for this answer Mark as a Correct answer

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