Search code examples
c#asp.netasp.net-controls

How to access a nested MultiView control in ASP.NET


I have an asp.net page with a multiview control nested within another multiview control. In my code behind I'm trying to access the inner most multiview control to set it's ActiveViewIndex. The problem I'm having is that I don't seem to be able to access the control. It's not available directly via this.MySubMultiview. And attempts to use this.FindControl or this.MyOuterMultiView.FindControl doesn't work.

Html: ... ...

Code behind: MultiView multiAddress = (MultiView)this.MultiViewMain.FindControl("MultiViewAddress"); multiAddress.ActiveViewIndex = 1;


Solution

  • I think the problem was that the control was also nested within a FormView control (I didn't mention that or realize that when I posted this question). So I was referencing the wrong "parent" to use FindControl.

    What I actually ended up doing was moving the panel outside the FormView where I could access the panel by name in the code behind.