Should HeaderText change the behavior of a GridView?

Discussion in 'ASP .Net Web Controls' started by Harry Keck, Feb 13, 2007.

  1. Harry Keck

    Harry Keck Guest

    I have a GridView control with a few columns declared directly in the aspx
    file. I have found that if I remove the HeaderText property from all columns
    that the GridView handles state completely differently than if any of the
    columns has a value set for HeaderText. This sounds completely wrong to me.
    Has anyone ever heard of this?

    When no columns have a HeaderText, the GridView maintains columns similarly
    to the old DataGrid. If I want to dynamically change the columns, I have to
    do it after every postback, or else the grid reverts back to the way it was
    originally declared in the designer.

    When at least one column does have a HeaderText, I can change the columns in
    the collection at any point and they will get retained across postbacks.
    However, if I change the columns collection at any point, all of my
    TemplateFields decalared in the designer get blanked out and render as empty.

    Why does HeaderText have such a drastic affect on my GridView, and how can I
    have columns with a HeaderText and not have my TemplateFields get emptied?
    Harry Keck, Feb 13, 2007
    #1
    1. Advertising

  2. Harry Keck

    Teemu Keiski Guest

    Replied to this at Forums
    http://forums.asp.net/thread/1576785.aspx

    --
    Teemu Keiski
    AspInsider, ASP.NET MVP
    http://blogs.aspadvice.com/joteke
    http://teemukeiski.net


    "Harry Keck" <> wrote in message
    news:...
    >I have a GridView control with a few columns declared directly in the aspx
    > file. I have found that if I remove the HeaderText property from all
    > columns
    > that the GridView handles state completely differently than if any of the
    > columns has a value set for HeaderText. This sounds completely wrong to
    > me.
    > Has anyone ever heard of this?
    >
    > When no columns have a HeaderText, the GridView maintains columns
    > similarly
    > to the old DataGrid. If I want to dynamically change the columns, I have
    > to
    > do it after every postback, or else the grid reverts back to the way it
    > was
    > originally declared in the designer.
    >
    > When at least one column does have a HeaderText, I can change the columns
    > in
    > the collection at any point and they will get retained across postbacks.
    > However, if I change the columns collection at any point, all of my
    > TemplateFields decalared in the designer get blanked out and render as
    > empty.
    >
    > Why does HeaderText have such a drastic affect on my GridView, and how can
    > I
    > have columns with a HeaderText and not have my TemplateFields get emptied?
    Teemu Keiski, Feb 14, 2007
    #2
    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. Andy Wang
    Replies:
    0
    Views:
    484
    Andy Wang
    May 12, 2004
  2. Øyvind Isaksen

    Change HeaderText in datagrid

    Øyvind Isaksen, Nov 6, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    3,937
    Eliyahu Goldin
    Nov 6, 2005
  3. Charly
    Replies:
    1
    Views:
    1,746
    hkjaja
    Feb 20, 2010
  4. Sharon
    Replies:
    1
    Views:
    1,385
    Kevin Frey
    Dec 1, 2006
  5. =?Utf-8?B?SGFycnkgS2Vjaw==?=

    Should HeaderText change the behavior of a GridView?

    =?Utf-8?B?SGFycnkgS2Vjaw==?=, Feb 13, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    467
    Teemu Keiski
    Feb 14, 2007
Loading...

Share This Page