Inserting web part fields via macro into TopN and WhereCondition attribute of QueryRepeater

D D asked on October 25, 2016 21:47

I've created a web part that I'm going to use as a widget that has 4 fields that content users can input info in. What I want to do is use those values in the query repeater to modify the number of records returned as well as modify the where condition.

In my code behind, I've created the public properties and I have access to it in the ascx front end file via normal C# server side scripting, however I can't inject them into the TopN and WhereCondition attribute.

For example, this doesn't work:

<cms:QueryRepeater ID="RptTest" runat="server" QueryName="Custom.TestPageType.QueryName" TransformationName="Custom.TestPageType.TransformationName" WhereCondition="Published = {%WebPartField %}"></cms:QueryRepeater>

I know I can use {%CurrentDocument["DocumentField"]#%} to get the current document. Is there an equivalent for web parts?

Thanks!

Correct Answer

Brenden Kehren answered on October 25, 2016 22:06

Set them in code behind like so:

RptTest.TopN = TopN;

Don't set them on the front ascx side.

1 votesVote for this answer Unmark Correct answer

Recent Answers


D D answered on October 25, 2016 22:13

Brilliant. Just what I needed. Thanks!

0 votesVote for this answer Mark as a Correct answer

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