You can loop through the Repeater items, extract the UserControl from there using FindControl method for you to get reference to the controls within the usercontrols.. I haven't tested on this since I'm not in my development environment but I think you
can do something like below at Button Click event:
foreach (RepeaterItem item in Repeater1.Items){
if (item.ItemType == ListItemType.AlternatingItem || item.ItemType == ListItemType.Item){
UserControl uc = (UserControl)item.FindControl("animation1");
if (uc != null){
//Access the checkbox that resides within the UserControl
CheckBox cb = (CheckBox) uc.FindControl("CheckBox1");
if(cb.Checked){
//Do something
}
}
}
}
vinz
All-Star
127026 Points
17936 Posts
MVP
Re: Accessing Repeater Item on Button Click
Jan 22, 2010 06:56 AM|LINK
You can loop through the Repeater items, extract the UserControl from there using FindControl method for you to get reference to the controls within the usercontrols.. I haven't tested on this since I'm not in my development environment but I think you can do something like below at Button Click event:
foreach (RepeaterItem item in Repeater1.Items){ if (item.ItemType == ListItemType.AlternatingItem || item.ItemType == ListItemType.Item){ UserControl uc = (UserControl)item.FindControl("animation1"); if (uc != null){ //Access the checkbox that resides within the UserControl CheckBox cb = (CheckBox) uc.FindControl("CheckBox1"); if(cb.Checked){ //Do something } } } }MessageBox Controls for WebForms | Blog | Twitter | Linkedin