Solved

Hiding Gridview Columns

Posted on 2006-11-09
2
514 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
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
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…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

813 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

16 Experts available now in Live!

Get 1:1 Help Now