Home > DeveloperSection > Forums > Adding User Controls from code behind
Ashish Pandey

Total Post:128

Posted on    September-29-2014 12:36 AM

 .NET C# 

 1 Reply(s)
 786  View(s)
Rate this:

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");




Sumit Kesarwani

Total Post:378

Posted on    September-29-2014 1:00 AM

Hi Ashish, 

Your code to add controls programmatically is right. Try doing,


instead of adding it to the controls. this looks like a control rendering issue.

Don't want to miss updates? Please click the below button!

Follow MindStick