Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C# ASP.NET
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 at 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
0 Sergey Alexandrovich Kryukov 271
1 OriginalGriff 223
2 nv3 50
3 VJ Reddy 45
4 Mehdi Gholam 45
0 Sergey Alexandrovich Kryukov 6,696
1 OriginalGriff 6,149
2 CPallini 2,473
3 Richard MacCutchan 1,697
4 Abhinav S 1,560

Advertise | Privacy | Mobile
Web01 | 2.8.140821.2 | Last Updated 4 Jul 2014
Copyright © CodeProject, 1999-2014
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