I'm doing something similar with an address user control.
Since you're adding the control dynamically, you will need to re-create the control after each post-back (each time you add another, you need to recreate ALL the previous controls you added).
I keep an arraylist of the control ID's (if you want viewstate to keep the contents, you need to create the controls with the same IDs) which also keeps track of how many controls I've previously added and need to recreate. I then loop through and create the controls again in my page load event:
foreach (string id in AddressItemIDs)
{
addAddressControl(null, id);
}
and then my "button1_click" event (in my case I'm using a link button...
protected void LinkButton1_Click(object sender, EventArgs e)
{
if (AddressCount == 0 || AddressCount < MaxAddresses && ((addressItem)addressContainer.Controls[addressContainer.Controls.Count-1]).HasAddress)
{
int i = 0;
string prefix = "addressItem_";
while (AddressItemIDs.Contains(prefix + i)) i++;
AddressCount++;
addAddressControl(null, prefix + i);
}
Button1.Visible = (AddressCount < MaxAddresses);
}
here is my addAddressControl method:
protected void addAddressControl(Address address, string id)
{
addressItem ai = (addressItem)LoadControl("~/controls/addressItem.ascx");
ai.RemoveClicked += new EventHandler(ai_RemoveClicked);
ai.ID = id;
if (address != null)
{
ai.AddressID = address.AddressID;
ai.Address = address.Street;
ai.City = address.City;
ai.State = address.State;
ai.Zip = address.Zip;
ai.TypeID = address.TypeID;
}
if(!AddressItemIDs.Contains(id))
AddressItemIDs.Add(id);
addressContainer.Controls.Add(ai);
}