?
Solved

ASP.Net and table - hide column

Posted on 2008-10-20
4
Medium Priority
?
548 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 16

Assisted Solution

by:Gyanendra Singh
Gyanendra Singh earned 800 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 800 total points
ID: 22755742
0
 
LVL 6

Accepted Solution

by:
AmarIs26 earned 1200 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

This article discusses four methods for overlaying images in a container on a web page
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 …
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Suggested Courses

777 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