Search code examples
asp.netmultiview

Is it possible to show two active indexes for a multiview at a time


I am having a multiview with

  Activeviewindex=-1.

I will have some views assume 3. In one view i will have a grid view placed and the other 2 views contain some controls. Now initially i will load the view with grid view now if the user clicks on radio button available in the grid view i would like to show the corresponding view along with grid view. But as per my thinking we can only show one view at a time. so is there any possibility to show 2 views of multiview at a time.


Solution

  • You might be better off placing your controls inside of <asp:Panel> controls and conditionally showing or hiding different panels in your code-behind. You can then show two at once, with the caveat that when you want to switch views, you have to manually hide all previously showing panels.

    Replace your existing MultiView:

    <asp:MultiView ... >
        <asp:View ID="View1" runat="server"> ... </asp:View>
        <asp:View ID="View2" runat="server"> ... </asp:View>
        <asp:View ID="View3" runat="server"> ... </asp:View>
    </asp:MultiView>
    

    With a series of Panels:

    <asp:Panel ID="View1" runat="server"> ... </asp:Panel>
    <asp:Panel ID="View2" runat="server"> ... </asp:Panel>
    <asp:Panel ID="View3" runat="server"> ... </asp:Panel>
    

    And show or hide them as needed:

    // switch to Panel #3
    protected void MyButton_Click(object sender, EventArgs e) {
        View1.Visible = false;
        View2.Visible = false;
        View3.Visible = true;
    }