Itemplate viewstate

Discussion in 'ASP .Net' started by =?Utf-8?B?QW1pbmU=?=, Jan 17, 2005.

  1. Hello,
    I am trying to create textbox control dynamically into a datagrid.
    I do not know the number of columns until run time so I thought I could use
    template columns dynamically and add them into the datagrid.
    This works fine, but on post back all the data in the datagrid disappears.
    Any idea why? I have the bad feeling that the view state has something to
    do with it.
    I do have viewstate enabled.
    Note: I am implementing the Itemplate interface and I have Implemented the
    InstantiateIn mehod.
    Thanks!
     
    =?Utf-8?B?QW1pbmU=?=, Jan 17, 2005
    #1
    1. Advertisements

  2. =?Utf-8?B?QW1pbmU=?=

    Karl Seguin Guest

    Controls which are created dynamically must be recreated dynamically on
    postback in order to exist.

    One solution is to use the OnItemCreated even to create the controls:
    http://openmymind.net/databinding/index.html#4.3

    Another might be to use Denis Bauer's free dynamic control placeholder,
    which might do the trick:
    http://www.denisbauer.com/ASPNETControls/DynamicControlsPlaceholder.aspx

    Karl

    --
    MY ASP.Net tutorials
    http://www.openmymind.net/


    "Amine" <> wrote in message
    news:...
    > Hello,
    > I am trying to create textbox control dynamically into a datagrid.
    > I do not know the number of columns until run time so I thought I could

    use
    > template columns dynamically and add them into the datagrid.
    > This works fine, but on post back all the data in the datagrid disappears.
    > Any idea why? I have the bad feeling that the view state has something to
    > do with it.
    > I do have viewstate enabled.
    > Note: I am implementing the Itemplate interface and I have Implemented the
    > InstantiateIn mehod.
    > Thanks!
    >
     
    Karl Seguin, Jan 17, 2005
    #2
    1. Advertisements

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. Ben Rush
    Replies:
    2
    Views:
    767
    Ben Rush
    Dec 5, 2003
  2. Steph
    Replies:
    2
    Views:
    1,888
    heislord5
    May 11, 2011
  3. ujjc001
    Replies:
    0
    Views:
    1,565
    ujjc001
    Jul 27, 2005
  4. sck10
    Replies:
    6
    Views:
    1,226
    sck10
    Sep 1, 2006
  5. mark

    Viewstate errors... how do I get viewstate working?

    mark, Feb 20, 2004, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    432
  6. Josema
    Replies:
    2
    Views:
    569
  7. Josema
    Replies:
    0
    Views:
    342
    Josema
    May 9, 2005
  8. George

    Persist viewstate in ITemplate child controls

    George, Nov 13, 2009, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    1,216
    George
    Nov 13, 2009
Loading...