Add Remove

  1. #1

    Add Remove

    Hi all :
    From a button I need to add items such as combobox and textfield
    but also removes the last you've added
    The first part is ready, I can add items, but do not know how to remove
    could someone please help me
    thank you very much


    
    using System;
    using System.Data;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using Ext.Net;
    
    namespace Example
    {
        public partial class Example1000 : System.Web.UI.Page
        {      
            Button btnAdd = new Button();
            Button btnRemove = new Button();
            ComboBox cb1 = new ComboBox();
            ComboBox cb2 = new ComboBox();
            TextField tfOrder = new TextField();
            CompositeField cf = new CompositeField();
            Ext.Net.Panel panel = new Ext.Net.Panel();
    
            protected void Page_Load(object sender, EventArgs e)
            {
                panel.Frame = true;
                panel.ID = "panel";
    
                btnAdd.Text = "Add";
                btnAdd.DirectClick += AddButton;
    
                btnRemove.Text = "Remove";
                btnRemove.ID = "Remove";
             
                panel.Items.Add(btnAdd);
                panel.Items.Add(btnRemove);
    
                this.form1.Controls.Add(panel);            
            }
    
            protected void Remove(object sender, DirectEventArgs e)
            {
    
            }
    
            protected void AddButton(object sender, DirectEventArgs e)
            {
                cb1.ID = "CbOrder";
                cb1.EmptyText = "Nothing";
                cb1.Editable = true;
                cb1.TypeAhead = true;
                cb1.Width = 170;
                cb1.Margins = "10 10 10 10";
    
                ListItem liOrder = new ListItem();
                liOrder.Text = "Item 1.1";
                ListItem liOrder2 = new ListItem();
                liOrder2.Text = "Item 1.2";
                ListItem liOrder3 = new ListItem();
                liOrder3.Text = "Item 1.3";
    
                cb1.Items.Add(liOrder);
                cb1.Items.Add(liOrder2);
                cb1.Items.Add(liOrder3);
    
                cb2.Width = 155;
                cb2.Margins = "10 10 10 10";
                cb2.EmptyText = "Nothing";
    
                ListItem liCriterio1_2_1 = new ListItem();
                liCriterio1_2_1.Text = "Item 1";
                ListItem liCriterio1_2_2 = new ListItem();
                liCriterio1_2_2.Text = "Item 2";
                ListItem liCriterio1_2_3 = new ListItem();
                liCriterio1_2_3.Text = "Item 3";
                            
                cb2.Items.Add(liCriterio1_2_1);
                cb2.Items.Add(liCriterio1_2_2);
                cb2.Items.Add(liCriterio1_2_3);
             
                tfOrder.ID = "tfOrder";
                tfOrder.Margins = "10 10 10 10";
    
                cf.Items.Add(cb1);
                cf.Items.Add(cb2);
                cf.Items.Add(tfOrder);
    
                cf.Render(panel);
            }     
        }
    }
  2. #2
    Hi,

    I can suggest this way:
    X.GetCmp<ComboBox>("ComboBoxClientID").Destroy();
    In your case a ClientID equals a server ID.
  3. #3

    ID

    But as I can do the incrementing ID

    for each item created is different
  4. #4
    I should save these IDs in some store, for example, Session.

    If you need to remove all items for a container, you can use the RemoveAll method.
    Container1.RemoveAll();

Similar Threads

  1. how to delete or remove record?
    By richard in forum 2.x Help
    Replies: 0
    Last Post: Jun 08, 2012, 9:12 AM
  2. HtmlEditor -- Remove <P> tag
    By bmagana in forum 1.x Help
    Replies: 0
    Last Post: Jun 09, 2011, 5:46 PM
  3. How remove VIEWSTATE?
    By luchexrb in forum 1.x Help
    Replies: 3
    Last Post: Jun 02, 2011, 8:41 PM
  4. Not able to add/remove tabs using DirectMethod
    By paul-2011 in forum 1.x Help
    Replies: 3
    Last Post: Mar 16, 2011, 10:17 PM
  5. remove dynamic controls
    By raks in forum 1.x Help
    Replies: 0
    Last Post: May 13, 2009, 10:34 AM

Tags for this Thread

Posting Permissions