Step1: Add all textboxes inside a panel. Here is the code:
In ASPX
<asp:panel id="pnlTextBoxes" runat="server" xmlns:asp="#unknown">
<asp:textbox id="textBox1" runat="server" />
<asp:textbox id="textBox2" runat="server" />
<asp:textbox id="textBox3" runat="server" />
<asp:textbox id="textBox4" runat="server" />
</asp:panel>
Step2: In this step you need to add code in your *.aspx.cs page. Here is the code:
In Code-behind
for(int i=1;i<=4;i++)
{
TextBox txtInstance = (TextBox)pnlTextBoxes.FindControl("textBox" + i);
if(txtInstance != null)
{
dataGridView1.Rows[i].Cells[i].Value = txtInstance.Text;
}
}