Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3679768
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:29:52+00:00 2026-05-19T03:29:52+00:00

So I have an <asp:Gridview> and in my C# file, I am setting the

  • 0

So I have an <asp:Gridview> and in my C# file, I am setting the datasource to some database table, and doing .DataBind().

However, I want to hide a column in the table based on a Boolean variable.

Something like this:

gridview.Columns['Field5'].Visible = false;

Or perhaps:

int c = gridview.Rows.Count();
for(int i = 0; i < c; i++){
  gridview.Rows['Field5'].Remove();
}

Perhaps I cannot make it invisible, but I’m sure I can at least loop through and remove all rows related to the column “field5”. I don’t know how to go about doing this.

Does anyone perhaps have a proper link to using the GridView Class and how all the methods are suppose to be used because it’s not clear, perhaps not written by microsoft?

Sorry if this is simplistic, the internet seems to lack a lot of C# documentation (or maybe it’s just cluttered with too much useless ASP.net information).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T03:29:53+00:00Added an answer on May 19, 2026 at 3:29 am

    In your case you should loop through gridview and set cells you want to hide Visible=false

            foreach (GridViewRow gvr in gv.Rows)
            {
                //here specify cell you want to hide  
                //also you may put any conditions
                gvr.Cells[0].Visible = false; // Hide cell
            }
    

    To hide column you should go like that:

            //here specify column you want to hide  
            grv.Columns[0].Visible = false; // Hide column
    

    Also check this article http://www.codeproject.com/KB/webforms/Datagrid_Col_Example.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have asp:GridView displaying client requests using asp:SqlDataSource . I want to limit displayed
I have an ASP.NET application inside which i have a GridView.I have Skin file
i have a gridview table like this... <div> <asp:GridView ID=GridView1 runat=server AllowSorting=true OnSorting=TaskGridView_Sorting >
I want to have an ASP C# WebSite that loads a simple CSV File
I have a gridview that I want to export to a .csv file. I
I have Gridview like this. Here is my last column Gridview code; <EditItemTemplate> <asp:TextBox
I have a gridview where one column is an Add / Remove asp:button which
I have a asp:GridView which contains a asp:TextBox within a TemplateField. I would like
I have a asp:GridView with a HyperLinkField . It's DataNavigateUrlFormatString property is set to
I currently have an asp:GridView that displays a few BoundFields and then one asp:TemplateField

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.