If you’re working entirely with DC then a transistor would work just as well and be a lot cheaper. Something like a 2N2222 would work, depending on how much current your solenoid pulls.
I see some 9v solenoids that only need 240mA so an 800mA transistor would work.