Nested Query Repeater

Cassandra Snyder asked on March 10, 2016 17:58

I have a custom table set up with rates for our credit cards. I have a query set up on a custom page type for accessing those rates. I have a different custom page type set up for our actual credit card page on our website. One of the fields of the credit card page type is for the query I have set up to access the credit card rate. Now on the credit card page template I have a regular repeater that I am using a nested repeater in the transformation of the regular repeater to display the credit card rate because there will be several credit card product pages with different rates and details but I am trying to avoid having different templates for each page. Now my question is, is it possible to use the transformation method of Eval() in the QueryName parameter of the nested repeater to get the credit card rate query that I have set up for accessing that rate in the custom table? Below is the code I currently have, but it doesn't seem to be working and I was wondering if this is even possible. The TierARate that you see in the code is the custom page type field that holds the query that I have set up in the format of "class code name.query name".

<script runat="server">    
      protected override void OnInit(EventArgs e)
  <cms:QueryRepeater runat="server" ID="CreditCardRate" QueryName='<%# Eval<string>("TierARate") %>' TransformationName="custom.Rates.CreditCardRateTransformationInternal" CacheMinutes="0" />

Recent Answers

Dawid Jachnik answered on March 11, 2016 09:00

Hello, I have working example how to do it. I have default repeater with the transformation

<div class="wiersz-rownych">
<cms:QueryRepeater runat="server" ID="produkty"></cms:QueryRepeater>
<a href="<%#ValidationHelper.GetString(Eval("Sciezka"),"/Lista").Replace("/%","")%>/Kategoria/<%#Eval("CategoryName")%>" class="wiecej">Więcej z tej kategorii <span class="icon-right-1"></span></a>
<script type="text/c#" runat="server">
protected override void OnDataBinding(EventArgs e)

  produkty.QueryName = "sitename.produkt_ksiazka.ZapytanieOgolne";
  produkty.Columns = "ClassName,NodeAliasPath,SKUImagePath,SKUname,StatusPubliczny,SKUPrice,Autor,NodeID,DocumentNamePath,FormatElibri,SKUID,SKUGUID,NodeLevel,NodeOrder,SKURetailPrice";
  produkty.TransformationName = "sitename.transformacjeProduktow.Default";
  produkty.SelectTopN = ValidationHelper.GetInteger(DataBinder.Eval(this.DataItem, "TopN"), 20);
  produkty.OrderBy = ValidationHelper.GetString(DataBinder.Eval(this.DataItem, "Sort"), "SKUName");

  string aliasPath = ValidationHelper.GetString(DataBinder.Eval(this.DataItem, "NodeAliasPath"), "");

  string where = "";
  where = CMS.DataEngine.SqlHelper.AddWhereCondition(where, "(NodeAliasPath like '" + aliasPath.Trim() + "/%' and (SKUTrackInventory='Disabled' or (SKUAvailableItems>0 and SKUSellOnlyAvailable=1) or SKUSellOnlyAvailable=0) and Published=1 and DocumentCulture='" + CMS.DocumentEngine.DocumentContext.CurrentDocumentCulture.CultureCode + "')");

  produkty.WhereCondition = where;

And it's working for me :)

2 votesVote for this answer Mark as a Correct answer

Cassandra Snyder answered on March 11, 2016 15:22

Thanks for your example, but that's not what I'm asking. My question is can I use this <%# Eval<string>("TierARate") %> in place of QueryName="custom.PageType.QueryName". I need to be able to use a custom page type form field to select the QueryName, not have it hard coded in.

0 votesVote for this answer Mark as a Correct answer

Trevor Fayas answered on March 11, 2016 16:34

Dawid's answer actually does cover this. Use his script function and set the

CreditCardRate.QueryName = Eval<string>("TierARate")+".QueryName"; or what not.

This allows you to dynamically alter the nested query repeater.

0 votesVote for this answer Mark as a Correct answer

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