Requirements: A set of identical controls, Lable1, Label2, Label3.....labeln, which need to be assigned values.
1. In general, use FindControl to find the name of the control, plus the sequence number. Below, my control names are: Lbl1,lbl2,lbl3,lbl4. Here, directly with the int type I, there is no problem.
for (int14; i++) { = (Label)this. FindControl ("lbl" + i); = i.tostring ();}
2. However, when the label group is in a container, this will cause an error. you need to find the container first, and then locate the label. as follows. Because the master page is used, the control group is actually in ContentPlaceHolder1, so first FindControl to ContentPlaceHolder1, FindControl to the Label control group.
for (int14; i++) { = (Label)this. Page.Master.FindControl ("ContentPlaceHolder1"). FindControl ("lbl" + i); = i.tostring ();}
Asp. NET control groups (Lable1, Label2, Label3.....labeln) are assigned