title: Setting a Textbox value within a GridView template field
body: <p>Within my load method of my page i want to set the Textbox in a templatefield to a value.</p>
  
  <p>Here is my current source code showing my template field textbox item 'txtQuan':</p>
  
  <pre><code>    &lt;asp:TemplateField&gt;
                &lt;ItemTemplate&gt;
                &lt;asp:Label ID="lblTotalRate" Text="Qty:" runat="server" /&gt;
                &lt;asp:TextBox ID="txtQuan" Height="15" Width="30" runat="server" /&gt;
  
                &lt;asp:Button ID="addButton" CommandName="cmdUpdate" Text="Update Qty"  OnClick="addItemsToCart_Click" runat="server" /&gt;
               &lt;/ItemTemplate&gt;
               &lt;/asp:TemplateField&gt;
  </code></pre>
  
  <p>And this is how im trying to set the TextBox value:</p>
  
  <pre><code> string cartQty = Qty.ToString();
  
   ((TextBox)(FindControl("txtQuan"))).Text = cartQty;
  </code></pre>
  
  <p>Im currently receiving a 'nullRefernceException error'. </p>