I have a DataTable
which contains column names and rows. Now as per my requirement I have to get only row value without giving the column names as I have done now.Here is the code.
data = employees.AsEnumerable().Select(row=> new List<string>
{
row.Field<string>("EmployeeName"),
row.Field<string>("Company")
})
In the above code employees
is DataTable
. How to do it.I have to get the row values into data
variable as shown in code.
Update
data = employees.AsEnumerable().Select(row=> new List<string>
{
foreach(DataRow row in employees.Rows)
{
foreach(DataColumn col in employees.Columns)
data.Add(row[col.Ordinal].ToString());
}
})