You can create a usercontrol (e.g. UserControl1) with a Textbox (e.g. id TextBox1) and one Button (e.g. id Button1). In the user control you can easily write Button_Click event.
Also, you create a public function SetValue(int i) to set the Text property of the Button
public void SetValue(int i)
{
Button1.Text = i.ToString();
}
In your page, you can do the following
protected void Page_Load(object sender, EventArgs e)
{
for (int i = 0; i < 5; i++)
{
UserControl1 uc = new UserControl1();
uc.SetValue(i);
template1.Controls.Add(uc);
}
}
Hope it helps