GridView w/ ITemplate Columns - Can't find data on Postback

Discussion in 'ASP .Net Web Controls' started by John, Oct 31, 2008.

  1. John

    John Guest

    I'm dynamically creating all the Columns in a GridView at run time and
    binding it to a DataTable. I have to build it at runtime (using an
    ITemplate subclass) because the number of columns is based on User
    input. All column cells are rendered as Textboxes. All Textboxs & the
    Grid have EnableViewState = True;

    Everything works fine except on Postback I can't seem to find the
    embeded Textbox controls that are needed to determine what the user
    has changed and be able to update the underlying Data table. Do
    Dynamically rendered controls come back in Viewstate???? They must,
    but I can't find them.

    on Page_Load (if it is a Postback) I build/rebuild the GridViews
    columns (I also tried in CreateChildControls)
    I do not bind the Data here because any user changes would be
    overwritten

    in Page_PreRender I try to Access the rows of the GridView but
    MyGrid.Rows.count = 0
    My intent is to update the DataTable with any cahnges and then Rebind

    Where can I access the Data the user entered on the Page?

    Thanks for any help!!
    -John
     
    John, Oct 31, 2008
    #1
    1. Advertising

  2. John

    myles Guest

    I had the same issue recently with the GridView. I ended up using a third
    party grid from Infragistics. This grid control has a RestoreTemplate event
    that you can use to restore all of your ITemplate based columns during a
    postback.

    Myles


    "John" <> wrote in message
    news:...
    > I'm dynamically creating all the Columns in a GridView at run time and
    > binding it to a DataTable. I have to build it at runtime (using an
    > ITemplate subclass) because the number of columns is based on User
    > input. All column cells are rendered as Textboxes. All Textboxs & the
    > Grid have EnableViewState = True;
    >
    > Everything works fine except on Postback I can't seem to find the
    > embeded Textbox controls that are needed to determine what the user
    > has changed and be able to update the underlying Data table. Do
    > Dynamically rendered controls come back in Viewstate???? They must,
    > but I can't find them.
    >
    > on Page_Load (if it is a Postback) I build/rebuild the GridViews
    > columns (I also tried in CreateChildControls)
    > I do not bind the Data here because any user changes would be
    > overwritten
    >
    > in Page_PreRender I try to Access the rows of the GridView but
    > MyGrid.Rows.count = 0
    > My intent is to update the DataTable with any cahnges and then Rebind
    >
    > Where can I access the Data the user entered on the Page?
    >
    > Thanks for any help!!
    > -John
    >
    >
    >
    >
     
    myles, Nov 3, 2008
    #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. cosine... zero
    Replies:
    0
    Views:
    671
    cosine... zero
    Jun 9, 2004
  2. Luhar Powell via .NET 247
    Replies:
    0
    Views:
    2,455
    Luhar Powell via .NET 247
    Apr 1, 2005
  3. John
    Replies:
    0
    Views:
    457
  4. David
    Replies:
    5
    Views:
    276
    Jeffrey Tan[MSFT]
    Feb 18, 2004
  5. Chuck P

    GridView ITemplate Columns

    Chuck P, Apr 16, 2007, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    210
    Steven Cheng[MSFT]
    Apr 17, 2007
Loading...

Share This Page