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>

ボタンをクリックしたときに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 に答える