title: jquery datepicker does not set date in ASP.net gridview EditItemTemplate and FooterTemplate's textBox
body: <p>I am trying to implement a VERY simple ASP.net page: A GridView that allows user to edit old entry or insert a new entry. One of the columns in the GridView is holiday, so I use Jquery's datepicker to allow user to select a date.</p>
  
  <p>Here is the ASP.net code</p>
  
  <pre><code>&lt;asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"&gt;
              &lt;asp:GridView ID="GridView1" runat="server" Height="300px"
                  ShowFooter="True"           
                  AutoGenerateColumns="false"
                  OnRowDeleting="GridView1_RowDeleting" 
                  OnRowEditing="GridView1_RowEditing"
                  OnRowUpdating="GridView1_RowUpdating"
                  OnRowCancelingEdit="GridView1_RowCancelingEdit"
                  OnRowCommand="GridView1_RowCommand" &gt; 
  
              &lt;Columns&gt; 
  
   &lt;asp:TemplateField HeaderText="Date"&gt;
                 &lt;EditItemTemplate&gt; 
                      &lt;asp:TextBox ID="txtEditDate" runat="server" Text='&lt;%# GetDate(Eval("CAL_DT")) %&gt;' OnLoad="DisplayDatePicker1" ReadOnly="true"&gt;&lt;/asp:TextBox&gt; 
                 &lt;/EditItemTemplate&gt;
                 &lt;FooterTemplate&gt; 
                      &lt;asp:TextBox ID="txtNewDate"  runat="server"  OnLoad="DisplayDatePicker2" ReadOnly="true"&gt;&lt;/asp:TextBox&gt;
                 &lt;/FooterTemplate&gt; 
                 &lt;ItemTemplate&gt; 
                      &lt;asp:Label ID="lblDate" runat="server" Text='&lt;%# GetDate(Eval("CAL_DT")) %&gt;'&gt;&lt;/asp:Label&gt;  
                 &lt;/ItemTemplate&gt; 
              &lt;/asp:TemplateField&gt;
          &lt;asp:TemplateField HeaderText="Edit" ShowHeader="False"&gt; 
              &lt;EditItemTemplate&gt; 
                &lt;asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update" Text="Update"&gt;&lt;/asp:LinkButton&gt; 
                &lt;asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel"&gt;&lt;/asp:LinkButton&gt; 
              &lt;/EditItemTemplate&gt; 
              &lt;FooterTemplate&gt; 
                &lt;asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="AddNew" Text="Add New"&gt;&lt;/asp:LinkButton&gt; 
              &lt;/FooterTemplate&gt; 
              &lt;ItemTemplate&gt; 
                &lt;asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit"&gt;&lt;/asp:LinkButton&gt; 
              &lt;/ItemTemplate&gt; 
          &lt;/asp:TemplateField&gt; 
             &lt;/Columns&gt;           
            &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>Here is my DisplayDatePicker1 method, DisplayDatePicker2 would be very similar.</p>
  
  <pre><code>protected void DisplayDatePicker1(object sender, EventArgs e)
  {
      StringBuilder scriptText = new StringBuilder();
      string clientID = (sender as TextBox).ClientID;
      scriptText.Append("$(function() {");
      scriptText.Append("var DateSelector1 = $('#" + clientID + "'); ");
      scriptText.Append("DateSelector1.datepicker();");
      scriptText.Append(" });");
      this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(),
                     "DateScript1", scriptText.ToString(), true); 
  }
  </code></pre>
  
  <p>So far so good. User can see the popup Datepicker and pick a date when he/she clicks Edit in the GridView row. Howerver, The following is the problem</p>
  
  <pre><code>protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
  {
      TextBox txtEditHoliday = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtEditHoliday");
      TextBox txtEditDate = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtEditDate");
      DropDownList dpdCountry = (DropDownList)GridView1.Rows[e.RowIndex].FindControl("dpdCountry");
  
      //txtEditDate.Text is not set,
  }
  </code></pre>
  
  <p>txtEditDate.Text still contains the <strong>old date</strong>.  The value selected by user via JQuery datepicker is not being passed to the txtEditDate.Text   Please help!  I spent many hours to search the internet but have not found any solutions.</p>