When we add dynamic textbox,checkbox or any control to gridview we have to add in a specific row with column, not in
datatable[
^].
TextBox tx = new TextBox();
then when you try to add TextBox in DataTable(which is wrong)
table.Rows.Add("student first name:", tx);
For Adding controls to GridView first of all add templatefield to gridview than on rowdatabound create controls of specific class with ID to add in that templatefield.
Here is a
link[
^] that will help you