When you live in a community with wildlife -- and that's pretty much anywhere -- a loose lid on your trashcan is an invitation to dinner for some roving scavenger. The method you choose to lock your trash cans depends on the type of visitors and the cunning they use when rummaging.
Video of the Day
Most trash cans have handles, and you can utilize them by stretching a bungee cord between them and over the lid. The bungee must be tight enough to require considerable effort on your part to connect it, or an enterprising raccoon will be able to remove it. You can use two bungee cords for added assurance, but simple bungee cords are not likely to discourage a bear.
If you live in bear country, consider reinforcing the front of your plastic trash bin with double-hinge safety hasps. Drill holes through the bin to attach the safety hasps on the sides of the trash bin so that they fold over the lid. Position the eye of the hasp through the hole in the hinge flat against the lid, and mark the location for securing it. You can then bear-proof the bin with a safety clip or padlock. Another method involves securing trash cans in a lockable wood or metal box.
You can use a similar approach to prevent your dog from opening you metal trash can. Instead of a padlock, you'll simply need a toggle lock. Screw one-half of the lock to the can and the other half to the lid, using a drill bit to make pilot holes for the nuts and bolts to secure the lock. Keep the can locked and Fido out of the trash when you aren't home.