5

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?

user2110845
  • 385
  • 8
  • 19

3 Answers3

9

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.

Hugo Nava Kopp
  • 2,906
  • 2
  • 23
  • 41
3

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.

Annu.
  • 31
  • 1
0

I got the same error initially but it worked correctly for me after deleting the previous view and replacing the views again

Below is the simple MultiView for the same

<asp:MultiView ID="MultiView1" runat="server">
    <asp:View ID="View1" runat="server">
                 <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        </asp:View>
        </asp:MultiView>
Lati
  • 1
  • 1