title: How to bind list<string> to a viewlist in ASP.NET
body: <p>I have a <code>List&lt;String&gt;</code> and I want to bind it to a <code>ListView</code> dynamically  Could you please tell me how to do it?</p>
  
  <pre><code>&lt;asp:ListView ID="ListView1" runat="server"&gt; 
      &lt;ItemTemplate&gt; 
          &lt;asp:Label ID="Label1" runat="server" Text="item: "&gt;&lt;/asp:Label&gt; 
          &lt;asp:Label ID="Label2" runat="server" Text='&lt;%# Eval("model") %&gt;'&gt;&lt;/asp:Label&gt;      
      &lt;/ItemTemplate&gt; 
  &lt;/asp:ListView&gt; 
  &lt;/td&gt;
  </code></pre>
  
  <p>this is the object class which i store in Session</p>
  
  <pre><code>public class ShoppingCart
  {
  
      List&lt;string&gt; cartContent;
  
      public ShoppingCart()
      {
          cartContent = new List&lt;string&gt;();
      }
  
      public List&lt;string&gt; Cart
      {
          get
          {
              return cartContent;
          }
      }
  </code></pre>
  
  <p>and here i insert items </p>
  
  <pre><code>((ShoppingCart)Session["cart"]).Cart.Add(lbtnModel.Text);
  </code></pre>
  
  <p>and here i ma binding </p>
  
  <pre><code>           List&lt;string&gt; ItemsList = ((ShoppingCart)Session["cart"]).Cart;
          ListView1.DataSource = ItemsList;
          ListView1.DataBind();
  </code></pre>
  
  <p>I want to set <code>Label2.text</code> dynamically </p>