1
It follows the code of how I create the 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 intend to take Textbox values.
Accordioncarros.Panes always come == 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 no exception, but checking by the immediate concigo see that the Accordioncarros.Panes always comes zeroed.
Why did you use this
try-catch
that does nothing?– Maniero
Thanks for the comment. Missed explain why Try Catch. Now I’ve edited the question.
– alexander Pataki
@alexanderPataki you have how to post the
Page_Load
of your page, because depending on how you load youracordion
by triggering thebutton
you may be losing the information ofviewstate
– Pablo Tondolo de Vargas
Another thing I’ve identified, I can’t find where in your method
CarregaAccordionCarros
is created theTextBoxCarro
, you will have to name your components at the time you add them toAccordion
label.ID = "NomeDoLabel";
– Pablo Tondolo de Vargas
@Pablovargas I edited the code again to show where I put the textbox id. In Page_load, you have nothing because I press Accordion from a button event.
– alexander Pataki
So try your own
ButtonSalvarCarro_Click
call again theCarregaAccordionCarros
, this before theforeach
– Pablo Tondolo de Vargas
@Pablovargas It was a good idea, since he would create everything again. But it also did not work.
– alexander Pataki
@alexanderPataki, you use some
UpdatePanel
? Put the codeaspx
if possible.– Pablo Tondolo de Vargas