Click here to Skip to main content
14,735,834 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Need to retrieve all textboxes value or id which is dynamically created inside Asp.net Panel in the same page...can you please how to do it.

What I have tried:

//Aspx controler//
<asp:panel id="pnlTextBoxes" runat="server" cssclass="Paneldetails">

//C# code//
TextBox txt = new TextBox();
txt.ID = results.data[i].name.ToString();
txt.CssClass = "tooltips";
txt.MaxLength = Convert.ToInt32(results.data[i].maxLength);
pnlTextBoxes.Controls.Add(txt);

//retriving textboxs value by using below code. but its not working//

customerParamsIds DSF = new customerParamsIds();
foreach (Control ctrl in pnlTextBoxes.Controls)
{
if (ctrl is TextBox)
{
DSF.name = ((TextBox)ctrl).ID;
DSF.value = ((TextBox)ctrl).Text;
summ.Add(DSF);
}
}
Posted
Comments
Sandeep Mewara 9-Nov-20 8:30am
   
first look, code looks okay to me - whats the problem?
Pradeep Rawat 9-Nov-20 23:35pm
   
Code is ok. but inside button click event I m trying to retrieve textboxes values.
/////
protected void btnAdd_Click(object sender, EventArgs e)
{
foreach (Control ctrl in pnlTextBoxes.Controls)
{
if (ctrl is TextBox)
{
DSF.name = ((TextBox)ctrl).ID;
DSF.value = ((TextBox)ctrl).Text;
summ.Add(DSF);
}
}
Sandeep Mewara 9-Nov-20 23:55pm
   
And what do you see when you debug it? code flow?
Pradeep Rawat 10-Nov-20 0:13am
   
when debug comes in if condition it's not going inside. It's goes out of condition . but when i am keeping textboxes inside panel from front end. then this code is working fine.. but I need a dynamically textboxes.......I hope you understand..may be its Postback problem...

how to reterive dynamically textboxes inside panel textboxes value when click on button

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900