title: How to fill a datatable with List<T>
body: <p>How can  convert a list to a datatable</p>
  
  <pre><code>[Serializable]
  public class Item
  {
      public string Name { get; set; }
      public double Price { get; set; }
      public string @URL { get; set; }
  
      public Item(string Name, string Price, string @URL)
      {
          this.Name = Name;
          this.Price = Convert.ToDouble(Price);
          this.@URL = @URL;
      }
  
      public override string ToString()
      {
          return this.Name;
      }
  }
  </code></pre>
  
  <p>I tried using:</p>
  
  <pre><code>static DataTable ConvertToDatatable(List&lt;Item&gt; list)
  {
      DataTable dt = new DataTable();
  
      dt.Columns.Add("Name");
      dt.Columns.Add("Price");
      dt.Columns.Add("URL");
      foreach (var item in list)
      {
          dt.Rows.Add(item.Name, Convert.ToString(item.Price), item.URL);
      }
  
      return dt;
  }
  </code></pre>
  
  <p>Now I'm getting a box show up but its empty! Help!! What can i do to make the box actually have data?</p>