title: Set Value Textbox Inside GridView Using Javascript
body: <p>I want the stored value in "val" and assgined to the textbox in the gridview.  I'm able to loop and find the rows but not the control. I'm getting a undefined error message. What I'm missing that I cannot find the control . Attached is the sample code:</p>
  
  <pre><code>&lt;!--Javascript Code--&gt;
  
  
  &lt;script type="text/javascript"&gt;
  function SetPIN(val)
  {
   if (Searching == 'eID')
  {
  
    var num = val;
    var grdvw = document.getElementById('gvEvents');
  
  
  for (var rowId = 1; rowId &lt; grdvw.rows.length -1; rowId++){
  var txtbx = grdvw.getElementById('txtEvtTo').value;
  
  txtbx = num;
  
  
   }end for
  
   }
   }
  
  &lt;/script&gt;
  </code></pre>
  
  
  
  <pre><code>  &lt;asp:GridView ID:gvEvents runat="server" AutoGenerateColumns="False" &gt;
    &lt;Columns&gt;
   &lt;asp:TemplateField&gt;
      &lt;ItemTemplate&gt;
   &lt;asp:TextBox ID="txtEvtTo" runat="server" Width="250px"&gt;&lt;/asp:TextBox&gt;
  &lt;/ItemTemplate&gt;
   &lt;/asp:TemplateField&gt;
   &lt;/Columns&gt;
   &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>I've tried different options that I've online but I haven't been able to get the value to textbox</p>
  
  <p>Any suggestions would be greatly appreciate it.  </p>
  
  <p>DR</p>