title: How do I find the Client ID of control within an ASP.NET GridView?
body: <p>I have a asp:GridView which contains a asp:TextBox within a TemplateField. I would like to obtain it's ID for use in javascript. Something like this:</p>
  
  <pre><code>&lt;asp:TemplateField&gt;
      &lt;ItemTemplate&gt;
          &lt;asp:TextBox ID="textDateSent" runat="server" /&gt;
          &lt;input type="button" value='Today' 
              onclick="setToday('&lt;%# textDateSent.ClientID %&gt;');" /&gt;
      &lt;/ItemTemplate&gt;
  &lt;/asp:TemplateField&gt;
  </code></pre>
  
  <p>But when I compile, I get an error:</p>
  
  <blockquote>
    <p>The name 'textDateSent' does not exist in the current context</p>
  </blockquote>
  
  <p>Anybody know how to get the client ID of this TextBox?</p>