See the following example and adapt to your needs:
Say in your aspx file you have a gridview control whose id is "GridView1";
on its code behind file > create a datatable > add the respective columns to the datatable > populate data row by row in the datatable > bind the datatable to GridView1
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack == true)
return;
DataTable dtTemp = new DataTable();
dtTemp.Columns.Add("Student ID");
dtTemp.Columns.Add("First Name");
dtTemp.Columns.Add("Last Name");
dtTemp.Rows.Add("1", "Peter", "Leow");
dtTemp.Rows.Add("2", "James", "Song");
dtTemp.Rows.Add("3", "Mick", "Sam");
dtTemp.Rows.Add("4", "MAry", "Cool");
GridView1.DataSource = dtTemp;
GridView1.DataBind();
}
The End.