You may be able to get a 9V battery to power the electromagnet for a reasonable period of time but it would require many turns of fine wire. The magnetic field of an electromagnet is determined by it's ampere-turns, so the more turns, the higher field for a given current.
For example 36AWG copper wire has a resistance of about 0.415Ω/ft. For 100mA of current, the needed wire coil resistance would be 9V/0.1 = 90Ω. This would require 90/0.415 = 216ft. of wire, giving 21.6 ampere-turns. Of course winding that much fine wire (36AWG is 5mil, about the size of a thick human hair) on a core without breaking it may require a coil winding machine.