title: Hide <TD> when there is nothing in gridview in ASP.NET using VB.NET
body: <p>I am trying to hide a TD named ImportnatInfo in a table when the gridview is empty. This gridview has one column from a table in a database to show. When this gridview is empty I want to hide the TD.</p>
  
  <p>The following is the asp code:</p>
  
  <pre><code>&lt;td runat ="server" ID="ImportnatInfo" 
                  style="width: inherit; border: 5px double #585858; padding-left: 5px; padding-right: 5px;
                  height: inherit; background: #FFFFFF; background-position: center; border-radius: 25px;" 
                  enableviewstate="True" visible="False"&gt;
                  &lt;asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BorderStyle="None"
                      DataSourceID="ImportantSqlDataSource"&gt;
                      &lt;Columns&gt;
                          &lt;asp:BoundField DataField="Importatnat_Info" SortExpression="Importatnat_Info"&gt;
                              &lt;ControlStyle BorderStyle="None" Height="10px" /&gt;
                              &lt;FooterStyle BorderStyle="None" Height="10px" /&gt;
                              &lt;HeaderStyle BorderStyle="None" Height="10px" /&gt;
                              &lt;ItemStyle BorderStyle="None" Height="10px" HorizontalAlign="Center" VerticalAlign="Middle" /&gt;
                          &lt;/asp:BoundField&gt;
                      &lt;/Columns&gt;
                  &lt;/asp:GridView&gt;
                  &lt;asp:SqlDataSource ID="ImportantSqlDataSource" runat="server" ConnectionString="&lt;%$ ConnectionStrings:AgainConnectionString %&gt;"
                      SelectCommand="SELECT [Importatnat_Info] FROM [StationInfoTable] WHERE ([StationNo] = @StationNo)"&gt;
                      &lt;SelectParameters&gt;
                          &lt;asp:ControlParameter ControlID="ddlStationNames" Name="StationNo" PropertyName="SelectedValue"
                              Type="Int32" /&gt;
                      &lt;/SelectParameters&gt;
                  &lt;/asp:SqlDataSource&gt;
                  &lt;br /&gt;
              &lt;/td&gt;
  </code></pre>
  
  <p>And the VB.net code is the following:</p>
  
  <pre><code>If GridView1.Rows.Count = 0 Then
          ImportnatInfo.Visible = False
      Else
          ImportnatInfo.Visible = True
      End If
  </code></pre>
  
  <p>I have dropdownlist and i choose something everytime so if there is nothing in the grid to view, i want the whole TD to be invisible. the TD that im trying to hide when it is empty, the thing the TD is always visible because when there is nothing in the gridView Vb add &nbsp; so it won't be empty. so i thought i should use the datasource and still not sure what to do. Any idea how to do that? </p>