Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Hiding Gridview Columns

Posted on 2006-11-09
2
Medium Priority
?
519 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 400 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

705 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