Solved

Hiding Gridview Columns

Posted on 2006-11-09
2
517 Views
Last Modified: 2012-08-13
I'm attempting to hide certain gridview boundfield and templatefield columns programmatically. The following code that references the column index works to hide a column.

GridView1.Columns(20).Visible = False

Is it possible to reference the gridview column by name (maybe the HeaderText) rather than the index (20)?

Thank you

0
Comment
Question by:mbowling
[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 Comments
 
LVL 16

Expert Comment

by:muzzy2003
ID: 17906467
No, only by iterating through the columns comparing the names.
0
 
LVL 28

Accepted Solution

by:
mmarinov earned 100 total points
ID: 17906514
Unfortunately you could not do this direct because the GridView.Columns collections does not allow it.
You can write your own method about this

    private sub HideColumnByName(name as string )

        For each column as DataControlField in GridView1.Columns
       
            if column.HeaderText = name then
                column.Visible = false
            end if
        Next
    End sub

Regards
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

630 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