title: Binding CheckBoxList to a Generic List
body: <p>How to bind a CheckBoxList to a generic list object. This sample code should work for the purpose:</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
      // Works well with the datatable as a data source
      //DataTable _entityList = new DataTable();
      //_entityList.Columns.Add("Id", typeof(int));
      //_entityList.Columns.Add("ProductName", typeof(string));
      //_entityList.Rows.Add(new object[] { 1, "First" });
      //_entityList.Rows.Add(new object[] { 2, "Second" });
  
      // Doesn't work with the generic list as a data source
      List&lt;MyProduct&gt; _entityList = new List&lt;MyProduct&gt;();
      _entityList.Add(new MyProduct(1, "First"));
      _entityList.Add(new MyProduct(2, "Second"));
  
      cblProducts.DataSource = _entityList;
      cblProducts.DataTextField = "ProductName";
      cblProducts.DataValueField = "Id";
      cblProducts.DataBind();
  }
  
  public class MyProduct
  {
      public int Id;
      public string ProductName;
      public bool selected;
  
      public MyProduct(int id, string desc, bool slctd)
      {
          this.Id = id;
          this.ProductName = desc;
          this.selected = slctd;
      }
  
      public MyProduct()
      {
          // TODO: Complete member initialization
      }
  }
  </code></pre>
  
  <p>But it is throwing a run time exception:</p>
  
  <p><strong>DataBinding: 'Test.MyProduct' does not contain a property with the name 'ProductName'.</strong> </p>
  
  <p>What am I missing? I tried google the topic but failed.</p>