Hi i am new to C# and wondering if there is something that exists to simplify what i am trying to do. I am using this sample to create a datatable from a class. Using Reflection to create a DataTable from a Class?
Question:
i would like to add rows to my datatable without individually populating each col. How would you add a row to this datatable from an object?
Sample:
DataTable dogTable = CreateDataTable(typeof(Dog));
grid.datasource = dogTable;
...
private void populateData(Dog newDog)
{
DataRow row;
...
//How do i populate without without going through each field ?? possible ?
//Since datatable was created from Dog there is a one to one relationship betwee
//datatable and dog class.
dogTable.Rows.Add(row);
}
Is there an easy way to put newDog in the table ?