title: How to build a ListView and fill it from the codebehind
body: <p>I want to fill my <code>ListView</code> from codebehind <em>and</em> want to know how to build the fields.
  I saw <a href="https://stackoverflow.com/q/11407221/1919644">this</a> example, and I'd like to now if the only way to build a <code>ListView</code>s fields is using tables. If not, what would be another way to do that?  I tried only filling the <code>ListView</code> with datasource, like this:</p>
  
  <pre><code>ListView1.DataSource = ds;
  ListView1.DataBind();
  </code></pre>
  
  <p>But it gave me an error:  </p>
  
  <blockquote>
    <p>An ItemTemplate must be defined on ListView 'ListView1'.</p>
  </blockquote>
  
  <p>What is the best way to use <code>ListView</code>?  The error happens only when I use <code>ListView1.DataBind();</code></p>
  
  <p>PS: I'll need only <strong>one</strong> row to display, so if someone has a better control to use than <code>ListView</code>, I'm reading.  </p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Now I'm trying like this:  </p>
  
  <pre><code>&lt;asp:ListView ID="ListView1" runat="server"&gt;
      &lt;LayoutTemplate&gt;
         &lt;table border="0" cellpadding="1"&gt;
             &lt;tr style="background-color: #E5E5FE"&gt;
                &lt;th align="left"&gt;&lt;asp:LinkButton ID="lnkResp" runat="server"&gt;&lt;/asp:LinkButton&gt;&lt;/th&gt;
                &lt;th align="left"&gt;&lt;asp:LinkButton ID="lnkProj" runat="server"&gt;&lt;/asp:LinkButton&gt;&lt;/th&gt;
                &lt;th align="left"&gt;&lt;asp:LinkButton ID="lnkFunc" runat="server"&gt;&lt;/asp:LinkButton&gt;&lt;/th&gt;
                &lt;th&lt;&gt;&lt;/th&gt;
             &lt;/tr&gt;
         &lt;/table&gt;
      &lt;/LayoutTemplate&gt;
      &lt;ItemTemplate&gt;
         &lt;tr&gt;
            &lt;td&gt;&lt;asp:Label runat="server" ID="lblResp"&gt;&lt;%#Eval("responsavel") %&gt;&lt;/asp:Label&gt;&lt;/td&gt;
            &lt;td&gt;&lt;asp:Label runat="server" ID="lblProj"&gt;&lt;%#Eval("projeto") %&gt;&lt;/asp:Label&gt;&lt;/td&gt;
            &lt;td&gt;&lt;asp:Label runat="server" ID="lblFunc"&gt;&lt;%#Eval("funcionalidade") %&gt;&lt;/asp:Label&gt;&lt;/td&gt;
         &lt;/tr&gt;
       &lt;/ItemTemplate&gt;
  &lt;/asp:ListView&gt;
  </code></pre>
  
  <p>But I got a <strong>new</strong> error:  </p>
  
  <p><code>An item placeholder must be specified on ListView 'ListView1'.<br>
  Specify an item placeholder by setting a control's ID property to "itemPlaceholder".<br>
  The item placeholder control must also specify runat="server".</code></p>