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. Karl Seguin

    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. cosine... zero
    Replies:
    0
    Views:
    784
    cosine... zero
    Jun 9, 2004
  2. cosine... zero
    Replies:
    0
    Views:
    842
    cosine... zero
    Jun 11, 2004
  3. Andrea Williams

    Datagrid binding to Itemplate Dropdown box

    Andrea Williams, Aug 5, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    4,646
    Andrea Williams
    Aug 5, 2004
  4. Luhar Powell via .NET 247
    Replies:
    0
    Views:
    2,560
    Luhar Powell via .NET 247
    Apr 1, 2005
  5. George

    Persist viewstate in ITemplate child controls

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

Share This Page