Can I use code-behind in RenderingTemplate? It's not possible to just use code-behind like using it in an application page.
What am I missing to use my own code inside a RenderingTemplate
You don't have code behind in rendering template, but you can create your own user control, which is part of rendering template. And your user control can have code behind.
Please visit this similar post for details.