// Create a data table object to put your data in
DataTable dt = new DataTable();
// Create a row object
DataRow dr;
// Add columns, label them and assign a data type
dt.Columns.Add(new DataColumn("UID", typeof(string)));
dt.Columns.Add(new DataColumn("First Name", typeof(string)));
dt.Columns.Add(new DataColumn("Last Name", typeof(string)));
dt.Columns.Add(new DataColumn("Title", typeof(string)));
dt.Columns.Add(new DataColumn("Dept", typeof(string)));
dt.Columns.Add(new DataColumn("Role", typeof(string)));
// Populate an array of strings for the table
string[] users = {"123","John","Doe","Mailman","Office Management","basic user"};
// create a new row
dr = dt.NewRow();
// Loop through the array and push it into the rows
for (int i = 0; i < 7; i++)
{
dr[i] = users[i];
}
// add the row to the table
dt.Rows.Add(dr);
// create a DataView object and apply the table to it
DataView dv = new DataView(dt);