How long are you immune to gastroenteritis after you have contracted it?

Unlikely to be. Gastroenteritis is a nonspecific term that reflects a stomach & intestinal infection by many agents. While you may gain some or total immunity to that virus, there are dozens of other viruses or bacteria that can cause gastro.Gastro is sort of like a car crash. You tangled with a dodge & got thru it, but a ford may get you next week.
Not at all. Perhaps the one specific viral strain, but there are many and they evolve/change rapidly, so no effective protection. Similar to how a virus can run through a family and then reinfect the early sufferers.