kalls
kalls

Reputation: 2865

How to make a HTML table <TD> invisible

I have a Grid View and I am checking some permission on the Grid View

If the user don't have permission. I am making the column invisible.

    Grid View.Column[9].visible = false; //Zero based index so column 10 will be invisible.

The GridView doesn't use GridView's header (because of a specific styling issue) but a separate html table.

the header is defined as follows

<tr>
            <td width="5%" class="hier-header">Column 1</td>
            <td width="10%"  class="hier-header"> Column 2 </td>
            <td width="10%"  class="hier-header"> Column 3</td>
            <td width="10%"  class="hier-header"> Column 4</td>
            <td width="5%"   class="hier-header"> Column 5</td>
            <td width="5%"   class="hier-header"> Column 6</td>
            <td width="10%"  class="hier-header"> Column 7 </td>
            <td width="15%"  class="hier-header"> Column 8 </td>
            <td width="5%"   class="hier-header"> Column 9 </td>
            <td width="5%"   class="hier-header"> Column 10 </td>
            <td width="5%"   class="hier-header"> Column 11</td>
            <td width="5%"   class="hier-header">Column 12</td>
            <td width="5%"   class="hier-header">Column 13</td>
    </tr>

In the above code I should make Column 10 not to show up. Is this doable?

Upvotes: 1

Views: 17003

Answers (4)

Antonio Bakula
Antonio Bakula

Reputation: 20693

You can do two things, hide column10 with css class (eg. Mr Lister answer) but then markup will be rendered and user can look in the source and see this data, so if you have some sensitive information in column10 you better set runat="server" and set visible to false, and column 10 will not be rendered in response html at all.

Upvotes: 0

Mr Lister
Mr Lister

Reputation: 46579

Give the td you want a new class. So that would be class="hier-header invisible". Then make everything with .invisible invisible using the stylesheet.

Upvotes: 0

sm13294
sm13294

Reputation: 563

You can simply add id to the column you want to be hidden then in backend set id.visible=false;

Upvotes: 0

Michael Liu
Michael Liu

Reputation: 55419

Add a runat="server" attribute to the <td> for Column 10 and give it an ID (like id="column10Header"). Then you can set its Visible property to false.

Upvotes: 6

Related Questions