Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9125461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:48:34+00:00 2026-06-17T06:48:34+00:00

I am trying to hide a TD named ImportnatInfo in a table when the

  • 0

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.

The following is the asp code:

<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">
                <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BorderStyle="None"
                    DataSourceID="ImportantSqlDataSource">
                    <Columns>
                        <asp:BoundField DataField="Importatnat_Info" SortExpression="Importatnat_Info">
                            <ControlStyle BorderStyle="None" Height="10px" />
                            <FooterStyle BorderStyle="None" Height="10px" />
                            <HeaderStyle BorderStyle="None" Height="10px" />
                            <ItemStyle BorderStyle="None" Height="10px" HorizontalAlign="Center" VerticalAlign="Middle" />
                        </asp:BoundField>
                    </Columns>
                </asp:GridView>
                <asp:SqlDataSource ID="ImportantSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:AgainConnectionString %>"
                    SelectCommand="SELECT [Importatnat_Info] FROM [StationInfoTable] WHERE ([StationNo] = @StationNo)">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="ddlStationNames" Name="StationNo" PropertyName="SelectedValue"
                            Type="Int32" />
                    </SelectParameters>
                </asp:SqlDataSource>
                <br />
            </td>

And the VB.net code is the following:

If GridView1.Rows.Count = 0 Then
        ImportnatInfo.Visible = False
    Else
        ImportnatInfo.Visible = True
    End If

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   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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T06:48:35+00:00Added an answer on June 17, 2026 at 6:48 am
            GridView1.DataBind()
        ImportnatInfo.Visible = True
        If GridView1.Rows.Count >= 1 Then
            If GridView1.Rows(0).Cells.Count >= 1 Then
                If GridView1.Rows(0).Cells(0).Text.Trim() = "&nbsp;" Then
                    ImportnatInfo.Visible = False
                Else
                    ImportnatInfo.Visible = True
                End If
            End If
        Else
            ImportnatInfo.Visible = False
        End If
    

    Yours is working good but you just need to add Else to show the TD after you check it is not  

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is probably an easy one but I want to hide variably named UI
i'm trying to hide/show some control on a page from Page_LoadComplete. If a put
I'm trying to hide all table rows that don't contain the string Marc from
I am trying to show/hide a table onclick of a checkbox and show another
I'm currently trying to hide a dynamically created table row after a button has
I am trying to hide a button in a table column based on another
Am trying to hide this publish 'tick-box' from non-admin users. I used the CanCan
I am trying to hide a Column from a grid using Peoplecode, but the
I am trying to use a slightly modified version of this code to show/hide
I have 5 buttons named opt1, opt2, opt3, etc. If I want to hide/show/do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.