Click here to Skip to main content
13,002,169 members (85,900 online)
Rate this:
Please Sign up or sign in to vote.
See more:
i wrote this code and get this error
An ItemTemplate must be defined on ListView 'ListView1'.

var data = from Student p in db.Students select p;
this.ListView1.DataSource = data;

what can i do ?
Posted 22-Feb-13 9:32am
Sergey Alexandrovich Kryukov 22-Feb-13 15:36pm
Well, Captain Obvious says: define ItemTemplate:,

Search for ItemTemplate in the second article referenced above, to see how to use it.

Rate this: bad
Please Sign up or sign in to vote.

Solution 4

Hi buddy

this link will help you because throwing the same error that you getting with solved....[^]

read that carefully

Happy to help
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

    <form id="form1" runat="server">
        <asp:DataList ID="DataList1" runat="server" Width="197px" BackColor="#DEBA84"
            BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CellPadding="3"
            CellSpacing="2" GridLines="Both">
            <FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
            <HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
            <ItemStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
               <asp:Label ID="w" runat="server" Text='<%#Eval("id") %>'></asp:Label>
               <asp:Label ID="Label1" runat="server" Text='<%#Eval("name") %>'></asp:Label>
               <asp:Label ID="Label2" runat="server" Text='<%#Eval("address") %>'></asp:Label>
            <SelectedItemStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />

protected void Page_Load(object sender, EventArgs e)
       if (!IsPostBack)
           DataClassesDataContext dcx = new DataClassesDataContext();
           var data = from c in dcx.TESTs
                      select c;
           DataList1.DataSource = data;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170624.1 | Last Updated 4 Jul 2014
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100