2
I created some controls TextBox
dynamically in my Code Behind and I need to redeem the values in a new method, but I cannot use the textbox
changed in a new method.
try
{
DataTable tbDadosAux =// Método para obter dados;
DataTable tbDados = //filtra dados
qtd.Value = tbDados.Rows.Count.ToString();
table1.HorizontalAlign = HorizontalAlign.Center;
table1.CssClass = ("table table-bordered table-hover table-striped");
if (tbDados.Rows.Count !=0)
{
tabela1.Visible = true;
}
for (int i = 0; i < tbDados.Rows.Count; i++)
{
TableRow linha = new TableRow();
TableCell c1 = new TableCell();
TableCell c2 = new TableCell();
TableCell c3 = new TableCell();
Label lblPesNm = new Label();
TextBox txtSeqNum = new TextBox();
HiddenField hdPesCodComp = new HiddenField();
c1.Text = tbDados.Rows[i]["RETORNO"].ToString();
c1.HorizontalAlign = HorizontalAlign.Left;
txtSeqNum.ID = "txtSeqNum" + (i + 1);
txtSeqNum.Text = tbDados.Rows[i]["SEQUENCIAL"].ToString();
c2.Controls.Add(txtSeqNum);
c2.HorizontalAlign = HorizontalAlign.Left;
table1.HorizontalAlign = HorizontalAlign.Center;
table1.CssClass = ("table table-bordered table-hover table-striped");
linha.Cells.Add(c1);
linha.Cells.Add(c2);
table1.Rows.Add(linha);
}
}
catch (Exception ex)
{
if (tran.Connection != null)
{
tran.Rollback();
conn.Close();
// Erro.InnerHtml = "Ocorreu o seguinte erro: " + ex.Message;
}
}
finally
{
if (tran.Connection != null)
{
tran.Commit();
conn.Close();
}
}
Why can’t you use it? Give more details.
– Jéf Bueno
I have tried to rescue like this: Textbox text= (Textbox)table1.Findcontrol("txtSeqNum" + 1);
– Germano Sampaio
And why doesn’t that work? I still can’t understand what your problem is. Try reading your question as someone who knows nothing about your project and see if you can understand anything.
– Jéf Bueno
I already solved it. I gave a request.Form[name].
– Germano Sampaio
You may even have succeeded with
Request.Form
, but, lost all page breaking the main link ...– Cezar