title: GridView How to get the value from a textbox in EDIT MDOE
body: <p>I have a gridview that has databound items. it is bound to a SQLDATASOURCE. The default Edit, Update works fine, however, i wanted to perform a query too when user updates the row.<br>
  Here is my aspx</p>
  
  <pre><code>  &lt;asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="Customer_id"
          DataSourceID="SqlDataSource1" 
          EmptyDataText="There are no data records to display." AllowPaging="True" 
          AllowSorting="True" CellPadding="4" ForeColor="#333333" GridLines="Horizontal" 
          PageSize="5" Width="873px"  OnRowCommand = "RunCustomMethod" &gt;
          &lt;AlternatingRowStyle BackColor="White" ForeColor="#284775" /&gt;
          &lt;Columns&gt;
              &lt;asp:TemplateField&gt;
                  &lt;EditItemTemplate&gt;
                      &lt;asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True"
                          CommandName="myCustomUpdateMethod" Text="Update" CommandArgument = '&lt;%# Eval("Customer_ID") %&gt;'
                          onclientclick="return Confirm ('Are You Sure You Want To Make These Changes?')"&gt;&lt;/asp:LinkButton&gt;
                      &amp;nbsp;&lt;asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" 
                          CommandName="Cancel" Text="Cancel"&gt;&lt;/asp:LinkButton&gt;
                  &lt;/EditItemTemplate&gt;
                  &lt;ItemTemplate&gt;
                      &lt;asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" 
                          CommandName="Edit" Text="Edit" &gt;&lt;/asp:LinkButton&gt;
                      &amp;nbsp;
                      &lt;asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" 
                          CommandName="Select" Text="Select"&gt;&lt;/asp:LinkButton&gt;
                      &amp;nbsp;
                   &lt;/ItemTemplate&gt;
              &lt;/asp:TemplateField&gt;
              &lt;asp:BoundField DataField="Customer_id" HeaderText="Customer_id" ReadOnly="True"
                  SortExpression="Customer_id" InsertVisible="False" /&gt;
              &lt;asp:TemplateField HeaderText="Customer_Name" SortExpression="Customer_Name"&gt;
                  &lt;EditItemTemplate&gt;
                      &lt;asp:TextBox ID="TextBox1" runat="server" Text='&lt;%# Bind("Customer_Name") %&gt;'&gt;&lt;/asp:TextBox&gt;
                  &lt;/EditItemTemplate&gt;
                  &lt;ItemTemplate&gt;
                      &lt;asp:Label ID="Label1" runat="server" Text='&lt;%# Bind("Customer_Name") %&gt;'&gt;&lt;/asp:Label&gt;
                  &lt;/ItemTemplate&gt;
              &lt;/asp:TemplateField&gt;
  
          &lt;/Columns&gt;
  
      &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>And here is my c# Code</p>
  
  <pre><code>  protected void RunCustomMethod(object sender, GridViewCommandEventArgs e)
          {
                  // Custom Method To Update Row
              if (e.CommandName == "myCustomUpdateMethod")
              {
                  int customerID = Convert.ToInt32(e.CommandArgument);
  
                     SqlConnection conn = new SqlConnection(SqlDataSource1.ConnectionString);
                  SqlCommand Cmd = new SqlCommand();
  
                  try
                  {
                      conn.Open();
  
                      Cmd.CommandText = "update Customers set customer_name = '" + **I WANT TO GET THE UPDATED VALUE BUT FROM WHERE SHALL I GET IT?????** + "', modified_on = getdate(), modified_by = '" + System.Environment.UserName + "' where customer_id = '" + customerID + "'";
                      Cmd.CommandType = System.Data.CommandType.Text;
                      Cmd.Connection = conn;
  
                      Cmd.ExecuteNonQuery();
                      GridView1.DataBind();
  
                      // Close the Edit Mode
                      GridView1.EditIndex = -1;
  
                  }
                  catch (SqlException ee)
                  {
  
                      ValidationError.Display(ee.Message);
  
                  }
  
                  finally
                  {
                      Cmd.Dispose();
                      conn.Close();
                      conn.Dispose();
  
                  }
              }
  
          }
  
      }
  </code></pre>
  
  <p>Any help would be greatly appreciated</p>