views:

431

answers:

1

I have only single "Default.aspx" page and a single ListView Control. Why am I getting this error. Never Happened before

"An item placeholder must be specified on ListView 'ListView1'. Specify an item placeholder by setting a control's ID property to "itemPlaceholder". The item placeholder control must also specify runat="server"."

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TesterConcepts._Default"%>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>

        </div>
        <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" 
            onselecting="ObjectDataSource1_Selecting" SelectMethod="GetItemsCollection" 
            TypeName="TesterConcepts.CutomDataSource">
            <SelectParameters>
                <asp:Parameter Name="items" Type="Object" />
            </SelectParameters>
        </asp:ObjectDataSource>
        <asp:ListView ID="ListView1" runat="server" DataSourceID="ObjectDataSource1" 
            onselectedindexchanged="ListView1_SelectedIndexChanged">
        </asp:ListView>    
    </body>
    </html>

doing this was not helpful even

<asp:ListView ID="ListView1" runat="server" DataSourceID="ObjectDataSource1"
     OnSelectedIndexChanged="ListView1_SelectedIndexChanged"
        ItemPlaceholderID="PlaceHolder1">
</asp:ListView>
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>

Now it throws this exception

"An item placeholder must be specified on ListView 'ListView1'. Specify an item placeholder by setting a control's ID property to "PlaceHolder1". The item placeholder control must also specify runat="server""

A: 

Looks like you need to define the placeholder element structure for the item elements which the query will return.

I'd suggest reading this article. A little old, but illustrates the concept. http://www.4guysfromrolla.com/articles/122607-1.aspx

Superstringcheese