Below is the sample code snippet that will do your work. You have to make sure where are you adding the control and also need to add event handler to peroform operation like RowDataBound, Edit, delete etc based on your requirments.
GridView gridView = new GridView();
gridView.ID = "gridViewDynamic";
gridView.AutoGenerateColumn=false;
gridView.DataSource = mydatasource;
gridView.DataBind();
Pages.Controls.Add(gridView);