views:

151

answers:

2

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;

A: 

Try this:

MultiView multiAddress = (MultiView)this.MultiViewMain.GetActiveView().FindControl("MultiViewAddress");
 multiAddress.ActiveViewIndex = 1;
alejandrobog
It Looks like it should work, but I tried this but it still returns a null. I'm not sure if something else could be hiding the control I'm looking for? Thanks for taking the time to respond.
Eden
A: 

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.

Eden