title: TextBox TextChanged Events not firing within a gridview
body: <p>I've got a databound grid view within a UpdatePanel.</p>
  
  <p>There are textboxes in the template fields which are dynamically created with a for loop.
  I have a textChange event associated with each textbox, but the event isn't being fired. 
  Please help me with it. </p>
  
  <p>Here's the ASP code:</p>
  
  <pre><code>&lt;asp:UpdatePanel ID="UpdatePanel1" runat="server"&gt;
      &lt;table width="100%"&gt;
          &lt;%--table for the grid view of buttons--%&gt;
          &lt;tr&gt;
              &lt;td align="center"&gt;
                  &lt;asp:GridView ID="gvJV" runat="server" AutoGenerateColumns="False" 
                      Height="100%" Width="749px" &gt;
                      &lt;Columns&gt;
                          &lt;asp:TemplateField HeaderText="Account"&gt;
                              &lt;ItemTemplate&gt;
                                  &lt;ajaxToolkit:ComboBox ID="AccountId" runat="server" AutoPostBack="false"&gt;
                                  &lt;/ajaxToolkit:ComboBox&gt;
                                  &lt;asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="AccountId"
                                      Display="Dynamic" ErrorMessage="Select Account" ForeColor="Red" InitialValue="-1"&gt;*&lt;/asp:RequiredFieldValidator&gt;
                              &lt;/ItemTemplate&gt;
                          &lt;/asp:TemplateField&gt;
                          &lt;asp:TemplateField&gt;
                              &lt;ItemTemplate&gt;
                                  &lt;asp:ImageButton ID="btnSelect" runat="server" ImageUrl="~/images/icons/edit.png" AutoPostBack="false"
                                      ImageAlign="AbsMiddle" OnClientClick='hdCallerRowID.value = this.parentElement.parentElement.rowIndex-1;' /&gt;
                                  &lt;ajaxToolkit:ModalPopupExtender ID="gv_ModalPopupExtender" runat="server" TargetControlID="btnSelect"
                                      PopupControlID="pnlSelectCOA" CancelControlID="btnCancel" BackgroundCssClass="modalBackground"&gt;
                                  &lt;/ajaxToolkit:ModalPopupExtender&gt;
                              &lt;/ItemTemplate&gt;
                          &lt;/asp:TemplateField&gt;
                          &lt;asp:TemplateField HeaderText="Memo"&gt;
                              &lt;ItemTemplate&gt;
                                  &lt;asp:TextBox ID="txtMemo" runat="server" BorderStyle="None" AutoPostBack="false"&gt;&lt;/asp:TextBox&gt;
                              &lt;/ItemTemplate&gt;
                          &lt;/asp:TemplateField&gt;
                          &lt;asp:TemplateField HeaderText="Debit"&gt;
                              &lt;ItemTemplate&gt;
                                  &lt;asp:TextBox ID="txtDebit" runat="server" AutoPostBack="false" OnTextChanged="txtDebit_textChanged" comm&gt;&lt;/asp:TextBox&gt;
                              &lt;/ItemTemplate&gt;
                          &lt;/asp:TemplateField&gt;
                          &lt;asp:TemplateField HeaderText="Credit"&gt;
                              &lt;ItemTemplate&gt;
                                  &lt;asp:TextBox ID="txtCredit" AutoPostBack="false" EnableViewState="true" runat="server" OnTextChanged="txtDebit_textChanged"&gt;&lt;/asp:TextBox&gt;
                              &lt;/ItemTemplate&gt;
                          &lt;/asp:TemplateField&gt;
                      &lt;/Columns&gt;
                  &lt;/asp:GridView&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
   &lt;/asp:UpdatePanel&gt;
  </code></pre>
  
  <p>and here's the code at back end</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.UI;
  using System.Web.UI.WebControls;
  using ERP.Controller;
  using System.Data;
  using AjaxControlToolkit;
  using MERP.WebUI.Code;
  using ERP.Properties;
  
  namespace MERP.WebUI.Account.GL
  {
      public partial class WebForm1 : System.Web.UI.Page
      {
  
          protected void Page_Load(object sender, EventArgs e)
          {
              if (!IsPostBack)
              {
                  txtCalendar_CalendarExtender.SelectedDate = DateTime.Now.Date;
  
                  BindGrid();
              }
          }
  
          private void BindGrid()
          {
              DataTable dt = new DataTable();
  
              dt.Columns.Add("Dummy");
  
              for (int i = 0; i &lt; 10; i++)
                  dt.Rows.Add("");
  
              dt.AcceptChanges();
  
              gvJV.DataSource = dt;
              gvJV.DataBind();
          }
  
  
  
          private void SaveForm()
          {
              int debitTotal = 0;
              int creditTotal = 0;
  
              foreach (GridViewRow gvRow in gvJV.Rows)
              {
  
                  TextBox txtDebit = (TextBox)gvRow.FindControl("txtDebit");
                  if (txtDebit.Text != string.Empty)
                      debitTotal += Convert.ToInt32(txtDebit.Text.Trim());
                  TextBox txtCredit = (TextBox)gvRow.FindControl("txtCredit");
                  if (txtCredit.Text != string.Empty)
                      creditTotal += Convert.ToInt32(txtCredit.Text.Trim());
              }
  
              if (debitTotal != creditTotal)
                  ((Authenticated)Master).SetMessage("NOT EQUAL");
              else
                  ((Authenticated)Master).SetMessage("done successfully");
          }
  
          protected void gvJV_RowDataBound(object sender, GridViewRowEventArgs e)
          {
              if (e.Row.RowType == DataControlRowType.DataRow)
              {
                  ComboBox AccountId = (ComboBox)e.Row.FindControl("AccountId");
                  Common.BindAccounts(AccountId);
                  TextBox txtMemo = (TextBox)e.Row.FindControl("txtMemo");
  
              }
          }
  
          protected void txtDebit_textChanged(object sender, EventArgs e)
          {
              GridViewRow row = ((GridViewRow)((TextBox)sender).NamingContainer);
              //NamingContainer return the container that the control sits in
              TextBox other = (TextBox)row.FindControl("txtCredit");
              other.Text = "";
          }
  
          protected void btnCancel_Click(object sender, EventArgs e)
          {
  
          }
  
          protected void btnSave_Click(object sender, EventArgs e)
          {
              SaveForm();
          }
  
      }
  }
  </code></pre>