Added TemplateColumn is not showing in DataGrid after PostBack

Discussion in 'ASP .Net Datagrid Control' started by Jade Seguin, Jul 13, 2004.

  1. Jade Seguin

    Jade Seguin Guest

    Hello,

    Hope somebody can help me with this cause I'm a ASP.NET beginner. I've
    created A DataGrid, and I added few BoundedColumns, and in my
    Page_Load section I added few TemplateColumns through the
    myGrid.Columns.Add(myTemplateColumn). After that I bind the datasource
    to the datagrid in the Page_Load only if it is not a postback.
    Initially it works fine, but on PostBack (whatever I do on the
    webform) my TemplateColumns dissapear :( Only the BoundedColumns stay.

    BTW. the code myGrid.Columns.Add(myTemplateColumn) is not in the If
    Not IsPostBack section, so it executes on each postback.

    Why doesn't it work? I thought you should only do the bind on the
    initial Page_Load and not on each postback, cause to me it seems like
    a lot of processing (i.e. database connections etc...)... Should it
    not be bound only once like my BoundedColumns which show fine on each
    postback?
    Jade Seguin, Jul 13, 2004
    #1
    1. Advertising

  2. This template columns has to added in datagrid itemcreated event handler and
    not in page_load. Since this template columns has to be created during
    every post back.

    --
    Saravana
    Microsoft MVP - ASP.NET
    www.extremeexperts.com



    "Jade Seguin" <> wrote in message
    news:...
    > Hello,
    >
    > Hope somebody can help me with this cause I'm a ASP.NET beginner. I've
    > created A DataGrid, and I added few BoundedColumns, and in my
    > Page_Load section I added few TemplateColumns through the
    > myGrid.Columns.Add(myTemplateColumn). After that I bind the datasource
    > to the datagrid in the Page_Load only if it is not a postback.
    > Initially it works fine, but on PostBack (whatever I do on the
    > webform) my TemplateColumns dissapear :( Only the BoundedColumns stay.
    >
    > BTW. the code myGrid.Columns.Add(myTemplateColumn) is not in the If
    > Not IsPostBack section, so it executes on each postback.
    >
    > Why doesn't it work? I thought you should only do the bind on the
    > initial Page_Load and not on each postback, cause to me it seems like
    > a lot of processing (i.e. database connections etc...)... Should it
    > not be bound only once like my BoundedColumns which show fine on each
    > postback?
    Saravana [MVP], Jul 14, 2004
    #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. NotYetaNurd
    Replies:
    1
    Views:
    448
    John Saunders
    Nov 7, 2003
  2. Jade Seguin
    Replies:
    2
    Views:
    468
    Elad Volpin
    Aug 2, 2004
  3. Ryu
    Replies:
    1
    Views:
    3,211
    Lucas Tam
    Aug 18, 2004
  4. Ray Booysen
    Replies:
    2
    Views:
    633
    Ray Booysen
    Mar 28, 2006
  5. Pete Mahoney

    Postback for DataGrid Columns Added in Code Behind not firing.

    Pete Mahoney, Aug 30, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    1
    Views:
    173
    Raghavendra T V
    Aug 31, 2004
Loading...

Share This Page