title: Workarounds to access the Readonly Textbox value on server side when changed through client side script
body: <p>I have a Date Textbox in each row of a Grid View. As the users must not be allowed to put their own values in the text box, we have set the property as ReadOnly="true". And provided a calender java-script plug-in which sets the Textbox value. Now when I am trying to access the date Textbox on save click, the Textbox value is not persisted. </p>
  
  <p>I knew about this issue and resolution for this too. We need to set the readonly attribute on server side to resolve this issue. But my biggest concern here is, I have placed the Textbox inside the Template field of Grid view. So I need to loop through each row of the Grid view, then get the reference to the date Textbox and then set the readonly attribute to readonly. Looks very cumbersome. Could anybody suggest other alternatives or work arounds.</p>
  
  <p>Code as Below</p>
  
  <pre><code>&lt;asp:GridView ID="gv_sample" runat="server" AutoGenerateColumns="false"&gt;
   &lt;Columns&gt;
     &lt;asp:TemplateField&gt;
       &lt;ItemTemplate&gt;
        &lt;table cellpadding="0" cellspacing="0" border="0"&gt;
         &lt;tr&gt;
          &lt;td&gt;
           &lt;asp:TextBox runat="server" ID="txtByWhen" ReadOnly="true" CssClass="inputbox" Text='&lt;%#Eval("ByWhen") %&gt;'&gt;&lt;/asp:TextBox&gt;
         &lt;/td&gt;
          &lt;td style="padding-left: 2px;"&gt;
           &lt;img src="../Images/dateico.gif" alt="Select a date" title="Select a date" 
           onclick="JavaScript:return showCalendar('&lt;%#((GridViewRow)Container).FindControl("txtByWhen").ClientID %&gt;','dd/mm/y');" /&gt;
        &lt;/td&gt;
       &lt;/tr&gt;
      &lt;/table&gt;
     &lt;/ItemTemplate&gt;
    &lt;/asp:TemplateField&gt;
   &lt;/Columns&gt;
  &lt;/asp:GridView&gt;
  </code></pre>