Hi @Coreysan ,
If you directly find the id is "txt2000",you could pass the value from txt1000 to txt2000.Just like this:
protected void Page_Load(object sender, EventArgs e)
{
for (int i = 1; i <=2; i++)
{
AddControls(i);
}
}
private void AddControls(int controlNumber)
{
var newPanel = new Panel();
var newLabel = new Label();
var newTextbox = new TextBox();
// textbox needs a unique id to maintain state information
newTextbox.ID = "TextBox_" + controlNumber;
newLabel.Text = "txt"+controlNumber+"000: ";
// add the label and textbox to the panel, then add the panel to the form
newPanel.Controls.Add(newLabel);
newPanel.Controls.Add(newTextbox);
newTextbox.AutoPostBack = true;
newTextbox.TextChanged += new System.EventHandler(this.txtBox_TextChanged);
form1.Controls.Add(newPanel);
}
private void txtBox_TextChanged(object sender, EventArgs e)
{
var x= (sender as TextBox).Text;
TextBox txt2 = (TextBox)form1.FindControl("TextBox_2");
txt2.Text = x;
}
Best regards,
Yijing Sun
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.