hide column in data grid

Discussion in 'ASP .Net Datagrid Control' started by BK Kim, Sep 16, 2003.

  1. BK Kim

    BK Kim Guest

    Hello.

    I just populated my datagrid but I need to hide one of the column.

    Since I need this column's data, I cannot drop that column from my store
    procedure.

    Is there a way I can make it invisible?

    I tried

    dataGrid1.Columns[1].visible = false;

    but didn't work and complained that I am out of index range.

    Any one know how to solve it?

    Thanx in advance
     
    BK Kim, Sep 16, 2003
    #1
    1. Advertising

  2. BK Kim

    Alvin Bruney Guest

    i've posted a solution to the hundred other places you posted this question
    "BK Kim" <> wrote in message
    news:...
    > Hello.
    >
    > I just populated my datagrid but I need to hide one of the column.
    >
    > Since I need this column's data, I cannot drop that column from my store
    > procedure.
    >
    > Is there a way I can make it invisible?
    >
    > I tried
    >
    > dataGrid1.Columns[1].visible = false;
    >
    > but didn't work and complained that I am out of index range.
    >
    > Any one know how to solve it?
    >
    > Thanx in advance
    >
    >
     
    Alvin Bruney, Sep 16, 2003
    #2
    1. Advertising

  3. And you couldn't post it a 101st time? :)

    Seriousely, what is the solution because I am having a similar problem. The
    only difference is that I have a databound grid with two fixed columns and
    am wanting the rest of them to be auto generated. The problem is that the
    two fixed columns get duplicated in the grid because I can't keep them from
    being auto-generated.

    Thanks,
    Craig

    "Alvin Bruney" <vapordan_spam_me_not@hotmail_no_spamhotmail.com> wrote in
    message news:...
    > i've posted a solution to the hundred other places you posted this

    question
    > "BK Kim" <> wrote in message
    > news:...
    > > Hello.
    > >
    > > I just populated my datagrid but I need to hide one of the column.
    > >
    > > Since I need this column's data, I cannot drop that column from my store
    > > procedure.
    > >
    > > Is there a way I can make it invisible?
    > >
    > > I tried
    > >
    > > dataGrid1.Columns[1].visible = false;
    > >
    > > but didn't work and complained that I am out of index range.
    > >
    > > Any one know how to solve it?
    > >
    > > Thanx in advance
    > >
    > >

    >
    >
     
    Craig Burkett, Sep 18, 2003
    #3
  4. BK Kim

    Alvin Bruney Guest

    101 and counting
    in your itemdatabound event do this:
    e.item.cells[9].visible = false;
    this will hide autogenerated columns. bound columns are part of the column
    collection so if you have 2 bound columns your index will be 0 and 1 and you
    would hide them the same way you were trying to hide them before. it can't
    work for autogenerated columns because they aren't part of the columns
    collection. ex if you have 2 bound columns and 4 autogenerated columns, you
    only have index 0 and 1 which is why you kept getting and index out of range
    when you tried to hide column 4. if you use the itemdatabound then you can
    hide the 4 autogenerated columns but not the 2 bound columns for the same
    reason

    hope this helps

    "Craig Burkett" <> wrote in message
    news:...
    > And you couldn't post it a 101st time? :)
    >
    > Seriousely, what is the solution because I am having a similar problem.

    The
    > only difference is that I have a databound grid with two fixed columns and
    > am wanting the rest of them to be auto generated. The problem is that the
    > two fixed columns get duplicated in the grid because I can't keep them

    from
    > being auto-generated.
    >
    > Thanks,
    > Craig
    >
    > "Alvin Bruney" <vapordan_spam_me_not@hotmail_no_spamhotmail.com> wrote in
    > message news:...
    > > i've posted a solution to the hundred other places you posted this

    > question
    > > "BK Kim" <> wrote in message
    > > news:...
    > > > Hello.
    > > >
    > > > I just populated my datagrid but I need to hide one of the column.
    > > >
    > > > Since I need this column's data, I cannot drop that column from my

    store
    > > > procedure.
    > > >
    > > > Is there a way I can make it invisible?
    > > >
    > > > I tried
    > > >
    > > > dataGrid1.Columns[1].visible = false;
    > > >
    > > > but didn't work and complained that I am out of index range.
    > > >
    > > > Any one know how to solve it?
    > > >
    > > > Thanx in advance
    > > >
    > > >

    > >
    > >

    >
     
    Alvin Bruney, Sep 19, 2003
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. C Newby
    Replies:
    7
    Views:
    610
    C Newby
    Apr 2, 2004
  2. Kevin Dahlhausen
    Replies:
    1
    Views:
    773
    Paul McNett
    Oct 4, 2004
  3. Keithb
    Replies:
    2
    Views:
    1,199
  4. Replies:
    3
    Views:
    409
  5. Eddie B.

    Hide data grid cols?

    Eddie B., Oct 17, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    149
    S. Spurlock
    Oct 17, 2003
Loading...

Share This Page