My 2 year old wouldn't stay in his bed, either, when he started climbing out of his crib. We took the side off his crib and put a baby gate in his doorway. I watched him very carefully when he first saw the new arrangement. We went into his room, I turned around and put up the gate, and then we did bedtime tuck-ins and stories. He immediately got out of bed (because he could) when I left, and that's when he really noticed the gate. He eyed it curiously, but I saw a tiny bit of relief on his face. His world was too big when he could get up at any time of the night and roam the entire house! But his bedroom he could handle.
That was back in the Fall. Now he stands at his gate and yells, "I don't want to go sleeeep!" and "Mom, where are you?" and "Mom, get this fence out of mine way!" but he always gets back in bed and goes to sleep!
Good luck.
BTW, we like our gate. It's gray plastic and is fairly easy to put in, and doesn't damage our doors. It was about $20 at Walmart. More than the cheap wood and white plastic ones, but I think it's better.