DataTable dt = new DataTable();
DataColumn dc1 = new DataColumn("Index", System.Type.GetType
("System.Int32"));
DataColumn dc2 = new DataColumn("Name", System.Type.GetType
("System.String"));
DataColumn dc3 = new DataColumn("Year", System.Type.GetType
("System.String"));
dt.Columns.Add(dc1);
dt.Columns.Add(dc2);
dt.Columns.Add(dc3);
int[] index = new int[] { 0, 1, 2, 3, 4, 5, 6, 7 };
string [] names= {"darren", "peter", "robin", "phil", "wayne", "rob", "doug", "sam"};
int[] year = new int[] { 1990, 19991, 1992, 1993, 1994, 1995, 1996, 1997 };
DataRow dr;
for (int i = 0; i < index.Length; i++ )
{
dr = dt.NewRow();
dr["Index"] = i;
dr["Name"] = names[i];
dr["Year"] = year[i];
dt.Rows.Add(dr);
}
|