title: Button and text box wont go Visible=false
body: <p>Hello I have a page which displays some information retrieved from the database. And I have a textbox and a button I want to hide when I get emptydataset from the database.</p>
  
  <p>This is the aspx code</p>
  
  <pre><code>&lt;asp:FormView ID="BookDetailView" runat="server" ItemType="WebApplication1.Models.Book" SelectMethod="GetBook" DeleteMethod="DeleteBook" RenderOuterTable="false"&gt;
      &lt;EmptyDataTemplate&gt;
          &lt;h1&gt;No book found!&lt;/h1&gt;
  
      &lt;/EmptyDataTemplate&gt;
      &lt;ItemTemplate&gt;
          &lt;div style="margin-left: auto; margin-right: auto; width: 50%;"&gt;
              &lt;div&gt;
  
  
                  &lt;h1&gt;&lt;b&gt;
                      &lt;asp:TextBox runat="server" BorderStyle="None" ReadOnly="true" Text="&lt;%#:Item.Title %&gt;" ID="bookTitleTextBox"&gt;&lt;/asp:TextBox&gt;&lt;/b&gt;&lt;/h1&gt;
  
              &lt;/div&gt;
  
  
  
              &lt;br /&gt;
              &lt;table style="margin-left: auto; margin-right: auto; width: 50%;"&gt;
                  &lt;tr&gt;
  
                      &lt;td&gt;&amp;nbsp;&lt;/td&gt;
                      &lt;td style="vertical-align: top; text-align: left;"&gt;
                          &lt;span&gt;&lt;b&gt;Book ID: &lt;/b&gt;&lt;asp:TextBox runat="server" BorderStyle="None" ReadOnly="true" Text="&lt;%#:Item.BookID %&gt;" ID="bookIDTextBox"&gt;&lt;/asp:TextBox&gt;&lt;/span&gt;
  
                          &lt;br /&gt;
                          &lt;span&gt;&lt;b&gt;Author:&lt;/b&gt;&amp;nbsp;&lt;%#:Item.Author %&gt;&lt;/span&gt;
  
  
  
                          &lt;br /&gt;
                          &lt;span&gt;&lt;b&gt;Published:&lt;/b&gt;&amp;nbsp;&lt;%#:Item.Published %&gt;&lt;/span&gt;
                          &lt;br /&gt;
                          &lt;span&gt;&lt;b&gt;Is borrowed:&lt;/b&gt;&amp;nbsp;&lt;asp:TextBox runat="server" BorderStyle="None" ReadOnly="true" Text="&lt;%#:Item.Borrowed %&gt;" ID="isBorrowedTextBox"&gt;&lt;/asp:TextBox&gt;&lt;/span&gt;
                          &lt;br /&gt;
                          &lt;asp:Button runat="server" Text="Delete" OnClick="DeleteBook" /&gt;
  
                          &lt;br /&gt;
  
  
  
                      &lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/table&gt;
  
  
          &lt;/div&gt;
      &lt;/ItemTemplate&gt;
  
  &lt;/asp:FormView&gt;
  
  
  &lt;asp:TextBox runat="server" placeholder="Borrow to user ID" ID="inputUserBorrow"&gt;&lt;/asp:TextBox&gt;
  &lt;asp:Button runat="server" ID="inputUserBorrowButton" Text="Borrow" Style="margin-left: 5px; margin-bottom: 10px;" OnClick="borrow" /&gt;
  &lt;br /&gt;
  </code></pre>
  
  <p>And this is the select method in the  code behind</p>
  
  <pre><code> public IQueryable&lt;Book&gt; GetBook([QueryString("BookID")] int? BookID)
      {
          var _db = new WebApplication1.Models.LibraryContext();
          IQueryable&lt;Book&gt; query = _db.Books;
          if (BookID.HasValue &amp;&amp; BookID &gt; 0)
          {
  
              query = query.Where(p =&gt; p.BookID == BookID);
          }
          else
          {
              query = null;
  
  
          }
  
          if (query == null) {
              inputUserBorrow.Visible = false;
              inputUserBorrowButton.Visible = false;
          }
          return query;
      }
  </code></pre>
  
  <p>Thank you for your help</p>
  
  <p>PS. If i put into the ItemTemplate the code will say that the textbox and the button are not know in the current context.</p>