Attaching a switch to wire shelving
May I suggest you solve the problem differently? Use a thin sheet  of aluminum, mount the panel to that using small self tapping screws, and then bend form the aluminum sheet at 90 degrees so that the switch faces front and there is a flat piece resting on the shelf top. Then, bind this piece to the shelf top using either bolts and washers, zipties or even something good &amp; heavy like a book... depending on your needs.

You'll get a more stable switch mount and it'll look better. Aluminum also takes paint well if you want to spray it or whatever to match the switch or your decor.