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. To maintain the view state of a dynamically created control

To maintain the view state of a dynamically created control

Scheduled Pinned Locked Moved ASP.NET
3 Posts 3 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.
  • S Offline
    S Offline
    sishya
    wrote on last edited by
    #1

    I created a drop downlist dynamically and i am unable to capture its values i.e its view state. I know that view state can't be retained for dynamically created controls .pls suggest a way out to retain the view state.

    M H 2 Replies Last reply
    0
    • S sishya

      I created a drop downlist dynamically and i am unable to capture its values i.e its view state. I know that view state can't be retained for dynamically created controls .pls suggest a way out to retain the view state.

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      Actually, the dynamic control can persist data in the ViewState as the static control does. The important thing when working with the dynamic control is that you need to choose the right event to readd the dynamic controls. If this happens after the ViewState is loaded, then it will loose its ViewState data. For more information, you should read about the control life cycle in MSDN.

      1 Reply Last reply
      0
      • S sishya

        I created a drop downlist dynamically and i am unable to capture its values i.e its view state. I know that view state can't be retained for dynamically created controls .pls suggest a way out to retain the view state.

        H Offline
        H Offline
        Hain Kurt
        wrote on last edited by
        #3

        if you want to see the selected value each time, it is easy... give it an ID, say idListBox. while creating it, get the value from form variables to determine the selected value: ... selVal = request.forms("idListBox") loop create a list item if value of the item = selVal then add "selected" to the item add item end loop ... That's it... HainKurt

        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