简体   繁体   中英

Why doesnt my ListView exist in current context?

The codebehind is acting like it doesn't see the aspx page.

This is the code behind:

protected void Page_Load(object sender, EventArgs e)
    {
        DashResultsViewModel dashResultsList = new DashResultsViewModel();

        ListView1.DataSource = dashResultsList.Display();

        ListView1.DataBind();
    }

This is the aspx page where it creates ListView1

<asp:ListView ID="ListView1" runat="server">
        <ItemTemplate>
            <asp:Label ID="Label1" Text="<%#Container.DataItem %>" runat="server" />
        </ItemTemplate>
    </asp:ListView>

The error: "The name 'ListView1' does not exist in the current context"

Question: How do I get it to work?

The connection between .aspx and .cs is somehow broken. Try deleting .designer.cs file and regenerating it by right clicking on relating .aspx and selecting Convert to Web Application from popup-menu. Good Luck

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM