title: Passing a variable from VB Code behind to aspx front end page
body: <p>I am trying to hide a link based on a variable value (groupId) on the code behind file.
  Below is what I tried based on various search results that I found on stack overlfow and else where.</p>
  
  <p>Approach 1 : </p>
  
  <pre><code>&lt;asp:HyperLink  ID="test_id" runat="server" 
           NavigateUrl='&lt;%#String.Format("report.aspx")%&gt;' 
           Text='Report' ToolTip="Generate Report" 
           ForeColor="#333399" Font-Names="Tahoma" Target = "_blank"
           &gt; 
          &lt;/asp:HyperLink&gt;
  </code></pre>
  
  <p>Code behind:</p>
  
  <pre><code>Dim groupId As String = ds.Tables(0).Rows(0).Item("GROUP_ID")
              'bmt_id.
              If (groupId = 0) Then
                  test_id.Visible=True;
  
              End If
  </code></pre>
  
  <p>Error : 'test_id' is not declared. It may be inaccessible due to its protection level.</p>
  
  <p>Approach 2: </p>
  
  <p>aspx page:</p>
  
  <pre><code>&lt;%If {&lt;%=groupId%&gt;} = 0 Then%&gt;
  
  &lt;asp:HyperLink  ID="test_id" runat="server" 
           NavigateUrl='&lt;%#String.Format("report.aspx")%&gt;' 
           Text='Report' ToolTip="Generate Report" 
           ForeColor="#333399" Font-Names="Tahoma" Target = "_blank"
           &gt; 
          &lt;/asp:HyperLink&gt;
  
       &lt;%End If%&gt;
  </code></pre>
  
  <p>Error : groupId not found error, during run time.</p>