I have a user control(UserControl1) on my page and one Add more button.Clicking on Add More Button add the same user control again.When i click on user control first time,it adds second User Control,but on second time it doesnot add other.I think the control gets lost. I am adding a control like this on link button click:-
protected void lnkadd_Click(object sender, EventArgs e) { HtmlTableCell tCell = new HtmlTableCell(); UserControl uc = (UserControl)Page.LoadControl("~/Controls/DirectionalPricingCtrl.ascx"); tCell.Controls.Add(uc); tablerow.Cells.Add(tCell); }
I think i am doing something wrong and i should add user controls in respect of page life cycle,but how?Can somebody please guide me or provide some useful links? What approach i should follow when i have to add a user control each time when i click on a Add button and then later retrieve all the values and save it to DB?