Load Components Dynamically

  1. #1

    Load Components Dynamically

    Hello,

    I have created a few Checkboxes dynamycally, but I dont find out how can I load them to set them true.

    Here is my code to create the CheckBoxes and it works pretty nice:
                    string categoria = Calzado;
                    foreach (Familia familia in Familias)
                    {
                        i++;
                        string nombrefamilia = familia.Nombre;
                        Ext.Net.Checkbox checkfamilia = new Ext.Net.Checkbox();
                        checkfamilia.ID = nombrecategoria.TrimEnd() + i;
                        checkfamilia.BoxLabel = nombrefamilia;
                        checkfamilia.MarginSpec = "0 0 0 60";
                        checkfamilia.Cls = "normalbox";
                        checkGroupfamilia.Add(checkfamilia);
                    }
                
            }
    As a result I get this:
    Click image for larger version. 

Name:	Screenshot-2017-9-26 Extranet Jhayber(1).png 
Views:	66 
Size:	4.5 KB 
ID:	25054

    Now I want to set checked=true in every checkbox below the checkbox "TODO" when I press it, but I cant find the way to do it because i cant load them:

     public void Marcartodas(object sender, DirectEventArgs e)
            {
                int categoriaID = Int32.Parse(e.ExtraParams["cat"].TrimEnd());
    
                DataBaseAccess dataBaseAccess = new DataBaseAccess(conexionBD);
                dataBaseAccess.open();
    
                CategoriaDao cat = new CategoriaDao(dataBaseAccess);
                Categoria categoria = cat.getById(categoriaID);
                
                FamiliaDao Fam = new FamiliaDao(dataBaseAccess);
                List<Familia> Familias = Fam.GetByCategoria(categoriaID);
                int i = 0;
                foreach (Familia familia in Familias)
                {
                    i++;
                    ¿¿¿¿¿¿(categoria.nombre + i).Checked = true????
    
                        
                }
            }
    Attached Thumbnails Click image for larger version. 

Name:	Screenshot-2017-9-26 Extranet Jhayber.png 
Views:	62 
Size:	7.5 KB 
ID:	25053  
  2. #2
    Hello @Pascu!

    What you create dynamically (from C# code on page load) will not be just available the next code behind call, just cause their scope is lost between requests in server-side.

    You would have to recall them again from the new code behind call before you could make changes to it.

    I'm afraid this is as far as we can get without a proper and runnable test case following our More Information Required guidelines and templates.

    Hope this helps!
    Fabrício Murta
    Developer & Support Expert
  3. #3
    So, There's no way to access to the checkboxes created dynamically?

    Edit: I found it
    foreach (Familia familia in Familias)
                    {
                        i++;
                        string vg = categoria.Nombre.TrimEnd() + i;
                        Checkbox check = (Checkbox)FindControl(vg);
                        check.Checked = true;
    
                    }
    Last edited by Pascu; Sep 27, 2017 at 4:10 PM.

Similar Threads

  1. [CLOSED] Ext components dynamically get and set propertys
    By siyahgul in forum 2.x Legacy Premium Help
    Replies: 7
    Last Post: Feb 21, 2015, 11:44 PM
  2. [CLOSED] How to dynamically load my menu in MVC
    By Tactem in forum 2.x Legacy Premium Help
    Replies: 7
    Last Post: Nov 27, 2013, 2:13 PM
  3. how to load image dynamically?
    By hongxue in forum 2.x Help
    Replies: 0
    Last Post: Sep 08, 2013, 7:45 AM
  4. [CLOSED] Loader to re-load Components dynamically
    By advBackOffice in forum 2.x Legacy Premium Help
    Replies: 9
    Last Post: Nov 26, 2012, 5:53 AM
  5. I better way to dynamically load windows?
    By dbassett74 in forum 1.x Help
    Replies: 6
    Last Post: Aug 13, 2009, 5:00 PM

Posting Permissions