2 Replies - 4435 Views - Last Post: 31 August 2013 - 08:35 AM Rate Topic: -----

#1 itzmePoulami  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 33
  • Joined: 12-March 13

Add ASP.NET controls dynamically

Posted 30 August 2013 - 10:45 PM

I have a radio button, a check box and a dropdownlist(bounded to database) in a panel along with an ADD button.
Now when i click on the ADD button, i want those three controls to repeat along with the ADD button and so on.

.aspx page code:
           <asp:Panel ID ="Panel2" runat ="server">
            <asp:CheckBox ID ="chck1" runat ="server" Text ="Select Me"/><br />
            <asp:RadioButton ID ="rbtn1" runat ="server" Text = "Click Me"/><br />
            <asp:DropDownList ID ="drpdwn1" runat ="server" ></asp:DropDownList><br />
            </asp:Panel>
            <asp:Button ID ="btnAdd" runat ="server"  Text ="ADD +" onclick="btnAdd_Click"/>
            <asp:PlaceHolder ID ="AddPlcHolder" runat ="server"></asp:PlaceHolder>



.aspx.cs page code:
     protected void btnAdd_Click(object sender, EventArgs e)
      {
        AddPlcHolder.Controls.Add(Panel2);
        AddPlcHolder.Controls.Add(new LiteralControl("<br>")); 
      }


Output:
The existing panel appears below the ADD button and no new panel is added.

I googled about it but I'm just not getting proper idea of doing it.
Please help.

This post has been edited by JackOfAllTrades: 31 August 2013 - 03:51 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Add ASP.NET controls dynamically

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 5954
  • View blog
  • Posts: 23,222
  • Joined: 23-August 08

Re: Add ASP.NET controls dynamically

Posted 31 August 2013 - 03:52 AM

After 30 posts you should know to use CODE TAGS!

:code:

Moved to ASP.NET.
Was This Post Helpful? 1
  • +
  • -

#3 Nakor  Icon User is offline

  • Professional Lurker
  • member icon

Reputation: 441
  • View blog
  • Posts: 1,488
  • Joined: 28-April 09

Re: Add ASP.NET controls dynamically

Posted 31 August 2013 - 08:35 AM

See if any of these previous answers help. (One of them was just a handful of posts below yours so maybe you read it already)

http://www.dreaminco...s-txtboxes-etc/
http://www.dreaminco...contols-values/
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1