Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MultiView cannot have children of type 'GridView'. It can only have children of type View

I have the following asp.net code

asp:MultiView runat="server" ID="mvPaymentsOnProperty" ActiveViewIndex="0">
    <asp:View runat="server" ID="vPaymentsMadeOnProperty">
        <br />
        <asp:GridView runat="server" ID="gvPaymentsMadeOnProperty" AutoGenerateColumns="false" EmptyDataText="bla bla">
            <Columns>
                <asp:BoundField HeaderText="bla" DataField="bla" />
                <asp:BoundField HeaderText="foo" DataField="bar" />
            </Columns>
        </asp:GridView>
    </asp:View>
    <asp:View runat="server" ID="vNoPaymentsMadeOnProperty">
        Some sort of error
    </asp:View>

</asp:MultiView>

When I try to load the page, I get the following error

MultiView cannot have children of type 'GridView'. It can only have children of type View.

I've collapsed the Multiview code and the only two children it has are the views. Is it complaining because of the contents of the view? Because otherwise that'd make it almost completely useless.

How do I fix this?

like image 682
user2110845 Avatar asked Feb 04 '14 10:02

user2110845


2 Answers

I was getting the exact error, but in my case I had forgotten to set runat="server" in the View control.

If one doesn't include runat="server" then that control simply doesn't exist for the backend. I hope this helps.

like image 54
Hugo Nava Kopp Avatar answered Sep 30 '22 15:09

Hugo Nava Kopp


This error means you have something outside your view tag. I.e. you have an asp element(other than view) in the multiview tag directly instead of being in the view tag.

Make sure you do not have a gridview in the multiview outside a view tag.

like image 23
Annu. Avatar answered Sep 30 '22 16:09

Annu.