In the itemtemplate template of repeater, we can use the items attribute to traverse rows and use findcontrol for search,
As shown below: traverse under the item command event of repeater:
For (INT I = 0; I <repeater1.items. Count; I ++)
{
Checkbox cb = (checkbox) repeater1.items [I]. findcontrol ("checkbox1 ");
If (CB. Checked)
{// Related data processing}
}
However, if the controls in the headertemplate and footertemplate templates are powerless, we can only use the CONTROLS attribute to solve the problem. Assume that the page contains the following Repeater control:
Program code <asp: repeater id = "repeater1" runat = "server">
<Headertemplate>
<Asp: Label id = "label1" runat = "server" text = "aaaaaaa"> </ASP: Label>
</Headertemplate>
<Itemtemplate>
<Asp: Label id = "label2" runat = "server" text = '<% # eval ("name") %>'> </ASP: Label>
</Itemtemplate>
<Footertemplate>
<Asp: Label id = "label3" runat = "server" text = "bbbbbbb"> </ASP: Label>
</Footertemplate>
</ASP: repeater>
BottomCodeFor example, find label1 and label3:
Program code // search for label1 in headertemplate. The default value is 0th string S = (Label) repeater1.controls [ 0 ]. Findcontrol ("label1"). Text; // search for label2 in footertemplate. The default value is the last string S = (Label) repeater1.controls [ Repeater1.controls. Count-1 ]. Findcontrol ("label2"). text;