Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Retaining viewstate of dynamic controls

Retaining viewstate of dynamic controls

Scheduled Pinned Locked Moved ASP.NET
helpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Krugger404
    wrote on last edited by
    #1

    Hi, I am currently building aproject management application. My current issue lies with a dynamic table which refreshes each time i choose a different project (from a dropdown). I used to create my controls (in the dynamic table) on PageLoad. This worked fine but however, the viewstate was retained when i chose another project eventhough i tried almost everything from EnableViewstate = false to many others... So, the quick fix was to actually create the dynamic controls in the "selectedIndexChanged" event of the project dropDown. This worked great. However, i am having a problem to updated data in one of these dynamic textboxes. If i change a value in the dynamic texbox and then click on "Save" button, i lose the viewstate of this textbox and it reverts to its previous value. Moreover, i do have dynamics dropdowns in the same table and they work fine, passing the changes. Can you please help me fix that out? Thanks beforehand dear friends. :omg: Krugger

    J 1 Reply Last reply
    0
    • K Krugger404

      Hi, I am currently building aproject management application. My current issue lies with a dynamic table which refreshes each time i choose a different project (from a dropdown). I used to create my controls (in the dynamic table) on PageLoad. This worked fine but however, the viewstate was retained when i chose another project eventhough i tried almost everything from EnableViewstate = false to many others... So, the quick fix was to actually create the dynamic controls in the "selectedIndexChanged" event of the project dropDown. This worked great. However, i am having a problem to updated data in one of these dynamic textboxes. If i change a value in the dynamic texbox and then click on "Save" button, i lose the viewstate of this textbox and it reverts to its previous value. Moreover, i do have dynamics dropdowns in the same table and they work fine, passing the changes. Can you please help me fix that out? Thanks beforehand dear friends. :omg: Krugger

      J Offline
      J Offline
      John ph
      wrote on last edited by
      #2

      whenever a control is added through controls.add() function, it goes through init,load and prerender. Add the dynamic textbox to the table or page before you set the property. this will enable the textbox to participate in the viewstate. Dim txtBox As New TextBox Table.Controls.Add(txtBox) txtBox.Text = "ABCDE" Regards John

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups