title: How to access a textbox text from gridview to a button Onclick event
body: <p>I am having textboxes and buttons in gridview. What I want is that when I click on those buttons the corresponding value in textbox is updated to database, so I need to access the textbox text in OnClick event. How can I do this?</p>
  
  <p>Gridview:</p>
  
  <pre><code>&lt;asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
              BackColor="#CCCCCC" BorderColor="#999999" 
              BorderStyle="Solid" BorderWidth="3px" CellPadding="4" CellSpacing="2" 
              ForeColor="Black" OnRowDataBound="GridView1_RowDataBound" 
              onselectedindexchanged="GridView1_SelectedIndexChanged"&gt;
              &lt;Columns&gt;
                  &lt;asp:TemplateField HeaderText="Save 1"&gt;
                      &lt;ItemTemplate&gt;
                          &lt;asp:TextBox ID="TextBox1" Width="30px" runat="server"&gt;&lt;/asp:TextBox&gt;
                          &lt;asp:Button ID="btnSave1" runat="server" Text="Save"  OnClick="btnSave1_Click" /&gt;
                      &lt;/ItemTemplate&gt;
                  &lt;/asp:TemplateField&gt;
                  &lt;asp:TemplateField HeaderText="Save 2"&gt;
                      &lt;ItemTemplate&gt;
                          &lt;asp:TextBox ID="TextBox2" Width="30px" runat="server"&gt;&lt;/asp:TextBox&gt;
                          &lt;asp:Button ID="btnSave2" runat="server" Text="Save"  OnClick="btnSave2_Click" /&gt;
                      &lt;/ItemTemplate&gt;
                  &lt;/asp:TemplateField&gt;
              &lt;/Columns&gt;
  &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>Button Onclick Event:</p>
  
  <pre><code>protected void btnSave1_Click(object sender, EventArgs e)
      {
           //I want to access TextBox1 here.
      }
  </code></pre>
  
  <p>Please help me out of this.</p>