How to get a TextBox from an Accordion that was generated dynamically?

1

Follow the code for how I create Accordion

   private void CarregaAccordionCarros()
   {                        
                //DataTable da Consulta
                var dtTable = GetDataCarro();


                AjaxControlToolkit.AccordionPane AccordionPane = null;
                Table tabela = null;

                foreach (DataRow dtRow in dtTable.Rows)
                {                    
                    AccordionPane = new AjaxControlToolkit.AccordionPane();
                    Label label;                    

                    label = new Label();
                    label.Text = dtRow[1].ToString();

                    //Head
                    AccordionPane.HeaderContainer.Controls.Add(label);

                    var textBox = new TextBox();
                    textBox.ID = "TextBoxCarro";
                    textBox.Text = dtRow[2].ToString();

                    var td = new TableCell();                    
                    td.Controls.Add(textBox);

                    var tr = new TableRow();
                    tr.Controls.Add(td);

                    tabela = new Table();   
                    tabela.Controls.Add(tr);

                    //Content
                    AccordionPane.ContentContainer.Controls.Add(tabela);

                    //Accordion
                    AccordionPergJustificativa.Panes.Add(AccordionPane);

                }
            }

Here is the Event in which I want to get the TextBox values.

  

AccordionCarros.Panes always comes == 0

protected void ButtonSalvarCarro_Click(object sender, EventArgs e)
{
    try 
        {           
            foreach (AccordionPane panes in AccordionCarros.Panes)
            {
                var textBox = (TextBox)panes.FindControl("TextBoxCarro");
                var str1 = textBox.Text;
            }
        }
        catch (Exception)
        {

            throw;
        }            
}
  

I left the Try Catch in the code, because here is no exception,   However, by checking immediately for the   AccordionCarros.Panes is always reset.

    
asked by anonymous 25.11.2014 / 12:04

0 answers