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

  • Home
  • SEARCH
  • 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 564659
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:47:25+00:00 2026-05-13T12:47:25+00:00

GridView1.Columns.Count is always zero even SqlDataSource1.DataBind(); But Grid is ok I can do for

  • 0

GridView1.Columns.Count is always zero even SqlDataSource1.DataBind();

But Grid is ok

I can do

for (int i = 0; i < GridView1.HeaderRow.Cells.Count;i++)

I rename request headers here
but

GridView1.Columns[i].Visible = false;

I can’t use it because of GridView1.Columns.Count is 0.

So how can I hide them ?

  • 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-13T12:47:25+00:00Added an answer on May 13, 2026 at 12:47 pm

    Try putting the e.Row.Cells[0].Visible = false; inside the RowCreated event of your grid.

    protected void bla_RowCreated(object sender, GridViewRowEventArgs e)
    {
        e.Row.Cells[0].Visible = false; // hides the first column
    }
    

    This way it auto-hides the whole column.

    You don’t have access to the generated columns through grid.Columns[i] in your gridview’s DataBound event.

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

Sidebar

Related Questions

Can anyone tell the function to sort the columns of a gridview in c#
protected void GridView1_DataBound(object sender, EventArgs e) { GridView1.Columns[0].ItemStyle.Width = 400; <asp:GridView ID=GridView1 runat=server DataSourceID=ObjectDataSource1
Simple thing get a list of columns present in the binded grid view, that's
I want to hide ID column in my GridView, I knew the code GridView1.Columns[0].Visible
Markup <asp:GridView ID=GridView1 runat=server AutoGenerateColumns=False> <Columns> <asp:BoundField DataField=insured_first_name HeaderText=First Name /> <asp:BoundField DataField=insured_first_name HeaderText=Middle
Markup: <asp:GridView ID=GridView1 runat=Server> <Columns> <asp:BoundField DataField=status_column HeaderText=Status /> <asp:BoundField ... <asp:BoundField ... </Columns>
I have an ASP.NET GridView which has columns that look like this: | Foo
I know it's possible to change some columns in GridView controls to check boxes
I have a GridView A that have many columns, one of those contains price
I currently have a gridview that has an asp:ButtonField as one of the columns.

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.