Session variable in Basic Repeater web part

A M asked on September 20, 2018 20:03

Hello,

I am using a Basic Repeater web part and trying to set the "Hide if no record found" property dynamically based on a session variable. It is my understanding that Kentico does not provide any "out of the box" macro to access the session variables, so I've built my own.

I also want to mention that I am using a Filter web part. The Filter web part has 3 drop down lists. By default I am not returning any results (this.WhereCondition = "1=0";). In this case I want to set "Hide if no record found" property to true. As soon as the user selects an option, I build the where condition and return the search results.
At this point I want to set "Hide if no record found" to false.
The goal is to display the error message only if the user selects an invalid combination of search criteria.
I set the session variable in the Filter's "SetFilter()" method based on the user's selection. I almost got it to work but I have a problem: whenever I select the search criteria, I need to click on the "apply filters" twice before I see the "no results found" error message.

Any idea what is causing this problem and how to fix it?

Thank you

Recent Answers


Suneel Jhangiani answered on September 21, 2018 12:49

I'd be certain that this is down to the Page Lifecycle and the timing of where the Session value is getting set and then read.

I think you will need to clone the Basic Repeater web part to create a custom version that will allow you to Recheck the 'Hide if no record found' value later in the lifecycle.

0 votesVote for this answer Mark as a Correct answer

A M answered on September 21, 2018 16:20

Thank you.

0 votesVote for this answer Mark as a Correct answer

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