How to connect a repeater to collection on button click?

Hi, I have a page with two repeaters,one dataset and a button to switch between repeater1 (List) and repeater2(Grid) . Connecting both repeater and then show/hide on button Click works but got performance issues. So, wondering if I can connect the dataset to repeater1 after a button click and then connect the dataset to repeater2 if I click the button again? thanks in advance !!

You should probably get the data from the dataset through code , save it to a variable (array), and that way you can switch out both repeaters’ data easily.