dynamic wherecondition on cms:QueryDataList

Diego Gutierrez asked on January 13, 2015 18:46

Hi folks, i have this cms:QueryDataList on my page.

<cms:QueryDataList runat="server" ID="lstItems1"  QueryName="custom.PageType.GET_FAVORITES" 
                        TransformationName="custom.PageType.RecetasFavoritas" RepeatDirection="Horizontal" RepeatLayout="Flow" CacheMinutes="0" WhereCondition="RF.FbId = '518734966'"></cms:QueryDataList>

and works perfectly, but it need to be dynamic so i tried the next code changing the wherecondition

if (client != null)
      {
          lstItems1.WhereCondition = "RF.FbId = '" + client.id + "'";   
        %>
                 <cms:QueryDataList runat="server" ID="lstItems1"  QueryName="custom.PageType.GET_FAVORITES" 
                        TransformationName="custom.PageType.RecetasFavoritas" RepeatDirection="Horizontal" RepeatLayout="Flow" CacheMinutes="0"></cms:QueryDataList>
        <%
      } %>

but thats show me all registers in the database, like if i remove the whole condition there. and of course, this other code didn't work at all.

<cms:QueryDataList runat="server" ID="lstItems1"  QueryName="custom.PageType.GET_FAVORITES" 
                        TransformationName="custom.PageType.RecetasFavoritas" RepeatDirection="Horizontal" RepeatLayout="Flow" CacheMinutes="0" WhereCondition="RF.FbId = '<%client.id%>'"></cms:QueryDataList>

how can i solve this??

Correct Answer

Brenden Kehren answered on January 13, 2015 19:45

You need to bind it similar to a nested repeater if you're doing this in a transformation. See this question and the answer(s) I've posted.

2 votesVote for this answer Unmark Correct answer

Recent Answers


Diego Gutierrez answered on January 13, 2015 20:04

thanks !

thats the correct answer! i only had to do this.

<script runat="server">
  protected override void OnInit(EventArgs e) 
  {
      if (client != null)
      {
          lstItems1.WhereCondition = "RF.FbId = '" + client.id + "'";
      }
  }
</script>
0 votesVote for this answer Mark as a Correct answer

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