Solved

ASP.Net and table - hide column

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Head to not include on scroll 4 23
Testing of the web services 1 34
Ouput in html in powershell 2 20
Overflow: auto does not stretch with position: absolute 3 17
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
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…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

828 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