Click here to Skip to main content
15,900,589 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Comments
Azee 4-Oct-13 1:12am    
What have you done so far? post your effort we'll take a look.
Manoj Ninganiya 4-Oct-13 1:22am    
protected void Checkheader_CheckedChanged(object sender, EventArgs e)
{
var item = ((CheckBox)sender).Parent as RepeaterItem;
CheckBox chkAll = item.FindControl("CheckAll") as CheckBox;
Repeater rpt = (Repeater)(sender as Control).Parent.Parent.Parent.Parent;
RepeaterItem rptitme =(RepeaterItem) rpt.FindControl("CheckSelect");
CheckBox chk = item.FindControl("CheckSelect") as CheckBox;
CheckBox chkchk = rpt.Controls[0].Controls[0].FindControl("CheckSelect") as CheckBox;
if (chkAll.Checked == true)
{

}

}


find above code "CheckSelect" checkbox in this block

1 solution

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,

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


Hope it helps.

Azee...
 
Share this answer
 
v2
Comments
Manoj Ninganiya 4-Oct-13 1:30am    
for (int i = 0; i < rptCC.Items.Count; i++)
{
CheckBox chk = (CheckBox)rptCC.Items[i].FindControl("CheckSelect");
if (chkAll.Checked)
{
chk.Checked = true;
}
}
like that boss
Manoj Ninganiya 4-Oct-13 1:33am    
but there is one problem all over thing is in nested repeater so first find outer repeater and then find inner repeater on CheckAll_CheckedChanged event so please tell me how to find repeaters

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900