These are some steps you need to follow in order to generating dynamic GridView.
I. Create a GidView object.
GridView gridview = new GridView();
II.Take a PlaceHolder in your page and write code for adding the GridView to PlaceHolder.
III. Now write the code for retrieving the value from database.
SqlConnection con = new SqlConnection(connectionstring);
SqlCommand cmd = new SqlCommand("select * from Emp", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
IV. Now bind the DataSet object with gridview.
gridview.DataSource = ds;
For more informaion about Dynamic GridView please go throuth this Article
And Please see solution 2 for rules of creating a dynamic controls.
Hope it will help you.