Hiding columns in GridView Control

Discussion in 'ASP .Net' started by Guest, Aug 3, 2006.

  1. Guest

    Guest Guest

    Hi,
    I have binded a dataset to a gridview control at run time.
    I'm fetching 5 columns from the database.
    But while displaying it on the screen i want to show only 3 columns.
    I tried with gridview.columns(i).visible property,but it did't work.

    Thanks in advance
    Srinivas
     
    Guest, Aug 3, 2006
    #1
    1. Advertisements

  2. Guest

    Winista Guest

    Are you adding the columns your self or using autoGenerate?
     
    Winista, Aug 3, 2006
    #2
    1. Advertisements

  3. Guest

    Guest Guest

    Hi,
    Thanks for the response.
    I DID NOT ADD ANY COLUMNS TO THE GRID VIEW AT DESIGN TIME OR AT RUN TIME.
    In the codebehind i'm just setting the datasource of the grid view as
    dataset which contains 5 columns of data.I require all 5 columns of data ,
    but while displaying it i want to hide some columns.

    Thanks
    Srinivas
     
    Guest, Aug 3, 2006
    #3
  4. Guest

    Winista Guest

    Winista, Aug 4, 2006
    #4
  5. Guest

    Guest Guest

    Hi Winista
    Thanks for the URL.
    But i'm using ASP.net gridview.
    The code that;s given in that url does't fit for it.

    Thanks
    Srinivas
     
    Guest, Aug 4, 2006
    #5
  6. Guest

    Winista Guest

    The same approach works for GridView. GridView also has RowDataBound and
    RowCreated events and you will use the same technique to remove the cell
    from row.
     
    Winista, Aug 4, 2006
    #6
  7. Guest

    rishibajaj4350

    Joined:
    Apr 17, 2009
    Messages:
    1
    Likes Received:
    0
    you can write this code in RowCreated Event of Gridview, assuming you want to hide first column

    e.Row.Cells[1].Visible = false;

     
    rishibajaj4350, Apr 17, 2009
    #7
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.