Solved

ASP.Net and table - hide column

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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…
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…
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 …

758 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

20 Experts available now in Live!

Get 1:1 Help Now