Solved

ASP.Net and table - hide column

Posted on 2008-10-20
4
536 Views
Last Modified: 2012-05-05
Hi

I have ASP.net page with <Table> and want to hide a column on page_load under some circumstances e.g.

IF ____ THEN
   Hide column
END IF

How do I do this?  

Thanks in advance
0
Comment
Question by:rwallacej
  • 2
4 Comments
 
LVL 16

Assisted Solution

by:Gyanendra Singh
Gyanendra Singh earned 200 total points
ID: 22755721
you need to add runat= server for your table ... and need to add id for each column... so on page load you will get access to id of column and you can do whatever you want
0
 
LVL 16

Assisted Solution

by:Gyanendra Singh
Gyanendra Singh earned 200 total points
ID: 22755742
0
 
LVL 6

Accepted Solution

by:
AmarIs26 earned 300 total points
ID: 22756067
runat="server requires an id to be specified however that will treat the cell the id is applied to as an indvidual cell and just hide that.

you need to specify the runat="server" attribute to the html table and then loop through the column and row and hide each cell indvidually.

    <table runat="server" id="testTable">
        <tr>
            <th>
                Col1
            </th>
            <th>
                Col2
            </th>
        </tr>
        <tr>
            <td>
                1234
            </td>
            <td>
                5678
            </td>
        </tr>
        <tr>
            <td>
                1234
            </td>
            <td>
                5678
            </td>
        </tr>
    </table>

--------------------------------------
Server side code

        for(int i=0;i<testTable.Rows.Count;i++)
        {
            //Cells[0] is the index of the column to hide.
            testTable.Rows[i].Cells[0].Visible = false;
        }


0
 

Author Closing Comment

by:rwallacej
ID: 31507738
thank-you very much in helping with this
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now