title: ASP.NET dynamic data listviewbinding
body: <p>I am having trouble with binding some data to a listview in ASP.NET.
  I am making a database mangement page where I can select a table from a database in a combobox.
  When you select the table, a listview appears with all the data of that table. Now I want to use databinding and i don't really know how to handle this.</p>
  
  <pre><code>&lt;asp:ListView ID="lvData" runat="server"&gt;
      &lt;LayoutTemplate&gt;
         &lt;table class="tableresults"&gt;
          &lt;thead&gt;
             &lt;tr class="odd"&gt;
                 &lt;th&gt;
                    &lt;%# Eval('COLUMNTITLE') %&gt;
                 &lt;/th&gt;
             &lt;/tr&gt;
          &lt;/thead&gt;
          &lt;tbody&gt;
             &lt;asp:PlaceHolder ID="ItemPlaceHolder" runat="server" /&gt;
          &lt;/tbody&gt;
         &lt;/table&gt;
        &lt;/LayoutTemplate&gt;
        &lt;ItemTemplate&gt;
          &lt;tr&gt;
            &lt;th scope="row"&gt;
               &lt;%# Eval('PROPERTY') %&gt;
            &lt;/th&gt;
           &lt;/tr&gt;
        &lt;/ItemTemplate&gt;
  &lt;/asp:ListView&gt;
  </code></pre>
  
  <p>So basically I need some kind of loop in the layouttemplate and itemtemplate that loops over the 'columntitles' and 'values' of the data I get from the database.
  Can I achieve this with databinding?</p>
  
  <p>So I just use code like this:</p>
  
  <pre><code>lvData.DataSource = getData();
  lvData.DataBind();
  </code></pre>
  
  <p>thx </p>