在转发器中,在headertemlate控件事件下查找itemtemplate的控件

在转发器中,在headertemlate控件事件下查找itemtemplate的控件

问题描述:

大家好,

i在转发器控制中面临一个问题

我的要求是在转发器的headertemplate一个复选框,当我点击复选框然后所有itmetemplate复选框选择并取消选择

hello all,
i have facing one problem in repeater control
my requirement is in headertemplate of repeater one checkbox when i click of checkbox then all itmetemplate checkbox select and deselect

嘿那里,



在标题复选框的 checkedChanged 事件,您需要循环遍历所有 Repeater 项目,使用 FindControl 查找CheckBox并设置其选中与标题复选框相同的值。例如,



Hey there,

In the header checkbox's checkedChanged event, you need to loop through all the Repeater items, find the CheckBox using FindControl and set its checked value same as the header checkbox. e.g,

CheckBox chkheader = (CheckBox) sender;
           foreach (RepeaterItem item in Repeater1.Items)
           {
               CheckBox chkItem = (CheckBox) item.FindControl("YourCheckBoxID");
               if (chkItem != null)
               {
                   chkItem.Checked = chkheader.Checked;
               }
           }





希望有所帮助。



Azee ......



Hope it helps.

Azee...