Solved

ASP.Net and table - hide column

Posted on 2008-10-20
4
539 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

832 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