0

以下是我的页面和控件层次结构。

Page
  UserControl 1
    <Repeater1> //Contents of UserControl 1
      UserControl 2
        <Accordion> //Contents of UserControl 2
        <Header/>
        <Content>
           <Repeater2/> //Repeater 2 is within Usercontrol 2
        <Button/>    // Button is within Usercontrol2, not Repeater 2
         </Accordion>
     </Repeater1>

我需要能够在Button click时刷新Repeater2

任何指针都会非常有帮助。

4

1 回答 1

0

将事件附加到按钮的单击。在该事件中,您应该能够遍历控件层次结构以到达 repeater2。

Button theButton = sender as Button;
UserControl2 parentControl = theButton.Parent as UserControl2;

Repeater theRepeater = null;
foreach(Control control in parentControl.Controls){
    theRepeater = control as Repeater;
    if(theRepeater != null) break;
}
于 2012-01-03T16:02:49.293 回答