Not sure if you know or not, but you place PlaceHolder1 in Panel1 on each iteration of the for loop. Perhaps you wanted to do Panel1.Controls.Add(PlaceHolder1); after the for loop?
In any case, you have placed these TextBox controls on the form. If you are trying to access them via postback, you need to either access them by their ID set, or access them through your asp containers (when setting runat="server" ):
x = (p1.Controls[placeHolderIndex].Controls[textBoxIndex] as TextBox).Text;
or you can try
x = (p1.FindControl("placeHolder_ID").FindControl("textBox_ID") as TextBox).Text;
make sure all runat="server" again
txtName will not retain its value after the postback.
Ask your second loop to do something more useful than overwriting the installed line as well; maybe add each value to the list
List<string> x = new List<string>(); for (i = 0; i < authors; i++) { x.Add((p1.Controls[placeHolderIndex].Controls[i] as TextBox).Text);
source share