Solved

Hiding Gridview Columns

Posted on 2006-11-09
2
512 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
Comment Utility
No, only by iterating through the columns comparing the names.
0
 
LVL 28

Accepted Solution

by:
mmarinov earned 100 total points
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This video discusses moving either the default database or any database to a new volume.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 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

12 Experts available now in Live!

Get 1:1 Help Now