<%# DataRowView.DataView.Count %> and The name 'DataRowView' does not exist in the current context

Lennard van Diggelen asked on September 30, 2016 10:53

Hi!

I'm trying to get the count of total items in a repeater but I cannot get it to work.

I've run through the whole internet en forum of kentico but no solution is working.

<%# DataRowView.DataView.Count %>

Why doesn't this work? (it is a cmsrepeater in an aspx file)

Recent Answers


Anton Grekhovodov answered on September 30, 2016 11:13

Hi,

In transformations you can use only transformation methods. Try to use <%# DataItemCount %>

0 votesVote for this answer Mark as a Correct answer

Lennard van Diggelen answered on September 30, 2016 11:17

Hi Anton!

thansk for the answer! However, it is not working. I get the error

CS0103: The name 'DataItemCount' does not exist in the current context

What am I missing here?

0 votesVote for this answer Mark as a Correct answer

Jan Hermann answered on September 30, 2016 12:31

It seems to me that you are not using Kentico transformations and you write your transformations directly to aspx markup of your pages.

0 votesVote for this answer Mark as a Correct answer

Lennard van Diggelen answered on September 30, 2016 12:49

But that is something I pointed out in my question:

Why doesn't this work? (it is a cmsrepeater in an aspx file)
0 votesVote for this answer Mark as a Correct answer

Joshua Adams answered on September 30, 2016 14:56 (last edited on September 30, 2016 14:58)

What about something like this:

Repeater1.Items.Count()

Also I believe that yours above didn't work because the transformation methods use Kentico's own repeater control(CMSRepeater) which has the properties above, whereas you are using a normal asp.net repeater from what it sounds like.

0 votesVote for this answer Mark as a Correct answer

Lennard van Diggelen answered on September 30, 2016 14:59

Hi Joshua,

Thank you for the reply.

Now I get Repeater1 does not exist in the current context. I'm really getting out of options here because the Id Repeater1 on the CMSRepeater does exist :(

0 votesVote for this answer Mark as a Correct answer

Joshua Adams answered on September 30, 2016 15:31

Repeater1 would need to be the actual id of your repeater.

1 votesVote for this answer Mark as a Correct answer

Jan Hermann answered on September 30, 2016 15:33

Move your transformation over to Kentico and link it within your repeater:

<cms:CMSRepeater runat="server" ID="cmsYourRepeater" TransformationName="CMS.SelectedPageType.my_trans" ...>
</cms:CMSRepeater> 
2 votesVote for this answer Mark as a Correct answer

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