yes, what TheChief said.
you need a transfer switch, or a few of them inline to control which source is feeding our panel. they make automatic transfer switches as well.
you can run solar, generator, utility company as multiple sources and switch between them. you can even run a battery array as a UPS for your entire house if you want...