title: Binding list of objects to ListView with a UserControl inside, problem
body: <p>I have a <strong>ListView</strong> containing a <strong>UserControl</strong> with a public property <strong>MyPublicProperty</strong> of type <strong>MyType</strong>.</p>
  
  <pre><code>public MyType MyPublicProperty{ get; set; }
  </code></pre>
  
  <p>I bind to ListView a list of items of <strong>MyType</strong> </p>
  
  <pre><code>listView.DataSource = (List&lt;MyType&gt;) items;
  listView.DataBind();
  </code></pre>
  
  <p>In aspx my ListView is defined like this</p>
  
  <pre><code>&lt;asp:ListView ID="listView" runat="server"&gt;
      &lt;ItemTemplate&gt;
          &lt;uc1:MyControl ID="myControl" runat="server" MyPublicProperty="&lt;%#(MyType)Container.DataItem %&gt;" /&gt;
      &lt;/ItemTemplate&gt;
  &lt;/asp:ListView&gt;
  </code></pre>
  
  <p>Now what happens is that in MyControl <strong>MyPublicProperty</strong> is not set at the event onDataBinding, and neither after that event.</p>
  
  <p>Do you happen to know why, and a solution for this ??
  <strong>EDIT:</strong>
  Looking more into the problems I observed that </p>
  
  <pre><code>listView.Items[0].DataItem 
  </code></pre>
  
  <p>is null after I call <strong>listView.DataBind()</strong>, but the list datasource has more then 1 items.</p>