how to check all check boxes in repeater control

K

kris

Hi All ,

I am using a repeater control to display set of records. Now on the
header template of the Reapeter control there is a Check Box .

For each record that will displayed there will be a check box assigned
to it.

now when i cllick the Check box on the header template all the check
boxes for the record displayed in repeater control have to be checked.

can any one help me in this, can any one provide me a code sample to
how do this.

Thanks
 
K

kris

I fiugured it out how to just do that.Propably if any one are searching
for somethig like this , this would be really helpful


protected void CheckAll(object sender, System.EventArgs e)
{
//sender= above sender in the function, who is sending that one
CheckBox cMain= (CheckBox) sender;//creating a new check box
if(cMain.Checked)//if checked header control
{

foreach(RepeaterItem ri in rpRepeater.Items)//checking all the
repeater items .. one line in rc is a item
if(ri.ItemType== ListItemType.Item)//if that item type is equal to
check box
{
CheckBox cb=(CheckBox) ri.FindControl("cBox");//find control named
cbox whicn is declared in
cb.Checked=true; //HTML
}
}
else// if again checked then de select all
{
foreach(RepeaterItem ri in rpRepeater.Items)
if(ri.ItemType== ListItemType.Item)
{
CheckBox cb=(CheckBox) ri.FindControl("cBox");
cb.Checked=false;
}
}

}
}

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top