ASPX templates
Version 6.x > ASPX templates > How to show total product? View modes: 
User avatar
Member
Member
hungquang_itsyad-yahoo.com - 8/2/2012 10:33:12 PM
   
How to show total product?
Hi, I want to show total product in cmsdatalist. I use cmsDatalist.Items.Count but it only show number of ech page.

How to show total products?

Thank!

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 8/3/2012 8:20:18 AM
   
RE:How to show total product?
Hello,

I am a bit confused by your description. Could you please let me know what do you mean by "total product"? Do you mean the total count of products or the total price?

Best regards,
Boris Pocatko

User avatar
Member
Member
hungquang_itsyad-yahoo.com - 8/13/2012 11:25:52 PM
   
RE:How to show total product?
total count of products

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 8/18/2012 5:17:30 PM
   
RE:How to show total product?
Hi,

could you please try to use:

<%# DataRowView.DataView.Count %>

It will display total number of items displayed by web part.

Best regards,
Ivana Tomanickova

User avatar
Member
Member
hungquang_itsyad-yahoo.com - 8/20/2012 12:56:52 AM
   
RE:How to show total product?
Hi, i use aspx template and cmsrepeater to show news, if insert <%# DataRowView.DataView.Count %>, it show Compilation Error: The name 'DataRowView' does not exist in the current context

<cms:CMSRepeater runat="server" ID="cmsRptListNews" Path="/{0}/{1}/%" ClassNames="CMS.News" OrderBy="NewsID DESC" EnableViewState="false" EnablePaging="True" PageSize="5" PagerControl-PagerPosition="Bottom">
<ItemTemplate>
<div><%# DataRowView.DataView.Count %>
<a href="<%# Eval("NodeAliasPath") %>.aspx">
<img src="<%# Eval("NewsTeaser","/getattachment/{0}/img.aspx?") %>" width="100px" height="100px" alt=""/></a>
<div>
<a href="<%# Eval("NodeAliasPath") %>.aspx"><h3><%# Eval("NewsTitle")%></h3></a>
<br />
<%# Eval("NewsSummary") %>
</div>
</div>
</ItemTemplate>
</cms:CMSRepeater>

User avatar
Kentico Support
Kentico Support
kentico_janh - 8/20/2012 1:45:17 AM
   
RE:How to show total product?
Hello,

Your code is ok, but it needs to be included as a part of transformation, so please take it:

<div><%# DataRowView.DataView.Count %>
<a href="<%# Eval("NodeAliasPath") %>.aspx">
<img src="<%# Eval("NewsTeaser","/getattachment/{0}/img.aspx?") %>" width="100px" height="100px" alt=""/></a>
<div>
<a href="<%# Eval("NodeAliasPath") %>.aspx"><h3><%# Eval("NewsTitle")%></h3></a>
<br />
<%# Eval("NewsSummary") %>
</div>
</div>


and place it to a new transformation in the Site Manager -> Development -> Document types -> News -> Transformation section and name it as "my_trans" and update your repeater code to contain the name of your transformation:

<cms:CMSRepeater runat="server" ID="cmsRptListNews" Path="/News/%" TransformationName="CMS.News.my_trans" ClassNames="CMS.News" OrderBy="NewsID DESC" EnableViewState="false" EnablePaging="True" PageSize="5" PagerControl-PagerPosition="Bottom">
</cms:CMSRepeater>


Best regards,
Jan Hermann