Create a datatable first and then bind the table on your gridview
DataTable dtAddGridView = new DataTable("TestTable");
protected void Add_Click(object sender, EventArgs e)
{
if (dtAddGridView.Rows.Count != 0)
{
if (dtAddGridView.Columns.Count != 0)
{
dtAddGridView.Columns.Add("Name", typeof(string));
dtAddGridView.Columns.Add("ID", typeof(int));
dtAddGridView.Columns.Add("Date", typeof(DateTime));
}
}
DataRow dr = dtAddGridView.NewRow();
dr["Name"] = "test";
dr["ID"] = 100;
dr["Date"] = DateTime.Now;
dtAddGridView.Rows.Add(dr);
GridView1.DataSource = dtAddGridView;
GridView1.DataBind();
}