title: Can't access the control in a listview
body: <p>Can't access the control in a listview</p>
  
  <p><strong>error</strong></p>
  
  <p>Object reference not set to an instance of an object.</p>
  
  <p><strong>.cs</strong></p>
  
  <pre><code>public void lnkaddtocart_Command(Object sender, CommandEventArgs e)
  {
    ((TextBox)ListView_ProductDetails.FindControl("txtbox_pqty")).Visible = false;   
  }
  </code></pre>
  
  <p><strong>.aspx</strong></p>
  
  <pre><code>&lt;asp:ListView runat="server" ID="ListView_ProductDetails"&gt;
       &lt;LayoutTemplate&gt;
          &lt;asp:PlaceHolder ID="itemPlaceholder" runat="server"&gt;&lt;/asp:PlaceHolder&gt;
       &lt;/LayoutTemplate&gt;
       &lt;ItemTemplate&gt;
                &lt;div class="qty"&gt;
                    Qty:
                    &lt;asp:TextBox ID="txtbox_pqty" Text="1" runat="server"/&gt;
                    &lt;input type="hidden" name="product_id" size="2" value="41" /&gt;
                         &lt;asp:LinkButton ID="lnkaddtocart" runat="server" 
                              CommandArgument='&lt;%#Eval("pid") %&gt;' 
                              OnCommand="lnkaddtocart_Command"  
                              cssclass="button"&gt;
                                 &lt;span&gt;Add to Cart&lt;/span&gt;
                          &lt;/asp:LinkButton&gt;
                    &lt;/div&gt;
      &lt;/ItemTemplate&gt;
  &lt;/asp:ListView&gt;
  </code></pre>