title: Create Dynamic properties from Datatable
body: <p>I have below class with one property.</p>
  
  <pre><code>  public class MfrYearEqpType
    {   
      public string EqpType { get; set; }
  
      public MfrYearEqpType()
      {
      }
    }
  </code></pre>
  
  <p>I wanted to create dynamic properties(Datatable column names) to my class "MfrYearEqpType" and set the values from below Datatable.</p>
  
  <p>DataTable dt = getData();</p>
  
  <p>This table contains 26 rows and 10 columns of data.</p>
  
  <p>I have gone through the below link. But I am not sure how to handle my case.</p>
  
  <p><a href="https://stackoverflow.com/questions/36686408/dynamically-adding-properties-to-an-object-from-an-existing-static-object-in-c-s">Dynamically adding properties to an Object from an existing static object in C#</a></p>
  
  <p>And also I have used <strong>ExpandoObject</strong>. I have done below sample.</p>
  
  <pre><code>  DataTable dt = getData();
  
    List&lt;dynamic&gt; expandoList = new List&lt;dynamic&gt;();
  
    foreach (DataRow row in dt.Rows)
    {
      //create a new ExpandoObject() at each row
     var expandoDict = new ExpandoObject() as IDictionary&lt;String, Object&gt;;
     foreach (DataColumn col in dt.Columns)
     {
        //put every column of this row into the new dictionary
        expandoDict.Add(col.ToString(), row[col.ColumnName].ToString());
     }
  
     //add this "row" to the list
     expandoList.Add(expandoDict);
     }
  </code></pre>
  
  <p>But my aim is to create the List of MfrYearEqpType. So that I can bind List of MfrYearEqpType to Gridview.</p>
  
  <p>Please help me on this. </p>