Filtering documents by Dates that are populated on drop down list

Idan Koren asked on December 30, 2020 09:17

Hi, I have page that display list of pages by using repeater. The repeater display the pages according the path field. I have created drop down list with the following text: - All Dates -Past 12 months -Past 6 months -Past 3 months

I would like when the user select item from the drop down list, the page will display only page according to the value of "DocumentCreatedWhen" field. Therefore the page should perform postback.

How can I do postback of the page after the user select item? How can I pass the value of the selected item to "WHERE condition" field on the repeater (and to be protected against SQL-injection)?

Thank you, Idan

Recent Answers


Juraj Ondrus answered on December 30, 2020 13:59

I would recommend using a filter to do the job as described in the filtering and paging data documentation. You can create a custom filter which will be basically just the drop down list. You can take inspiration in the existing "Page name filter" web part.
Or, another option would be adding some query string parameter to the URL - e.g. the drop down change event will add the parameter to the URL and in the repeater's WHERE condition you will use query string macro to read the value. Do not forget to supply default value in case parameter is missing, do not forget to sanitize the input to avoid SQLi.

0 votesVote for this answer Mark as a Correct answer

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