title: Asp.NET ListView Data Control Dynamically Databind
body: <p>I am trying to implement a ListView data control for displaying and editing lookup table/ application level variables. There are multiple entity classes which can be bound to the ListView, so the ItemTemplate needs to be dynamically bound to the selected entity object.</p>
  
  <p>For example i have: </p>
  
  <pre><code>AddressType { AddressTypeId, AddressTypeDescription}, 
  PhoneType { PhoneTypeId, PhoneType}, 
  MarriageStatusType { MarriageStatusId, marriageStatusType}
  </code></pre>
  
  <p>Those generated entity objects prevent me from simply doing something like the following snippet, because the ID and Type properties are different on each business object.</p>
  
  <pre><code>&lt;ListView&gt;
  ...
  
  &lt;itemTemplate&gt;
      &lt;tr&gt; 
         &lt;td runat="server" id="tdId"&gt; &lt;%# Eval("ID") %&gt; &lt;/td&gt; 
         &lt;td runat="server" id="tdType"&gt; &lt;%# Eval("TypeNameDescription") %&gt; &lt;/td&gt; 
      &lt;/tr&gt;
  &lt;/itemTemplate&gt;
  
  ...
  &lt;/ListView&gt;
  </code></pre>
  
  <p>I am trying to discover :
  1. How to iterate over the ListView Items to insert the appropriate property value into the server side html td tags.
  2. How to use Databinder.Eval on the ListView items to insert that property value.</p>
  
  <p>Thanks in advance!</p>