This should do what you want:
DataRow firstRow = table.NewRow(); List<string> names = new List<string>(); foreach (DataColumn column in table.Columns) { names.Add(column.ColumnName); } firstRow.ItemArray = names.ToArray(); table.Rows.InsertAt(firstRow, 0);
If the first line already exists and you want to βoverwriteβ this change, the first line:
DataRow firstRow = table.Rows[0];
And delete the last line.
source share