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. multiple instances of same user control

multiple instances of same user control

Scheduled Pinned Locked Moved ASP.NET
mcp
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.
  • K Offline
    K Offline
    kiran kumar Intelligroup
    wrote on last edited by
    #1

    Hi folks, I am breaking my head since two days. Here is the scenario. I have a user control with first name,last name,gender.Now i put this control in web page called employee.aspx. I have a button on that page "Add employee".for each click on that button i should add one user control. I tried in so many ways like taking for loop and adding user control but its not retaining state.It's loosing previous controls data. Please suggest me best approach with some sample code. Thanks in advance

    Kiran Kumar.CH (MCP)

    C B 2 Replies Last reply
    0
    • K kiran kumar Intelligroup

      Hi folks, I am breaking my head since two days. Here is the scenario. I have a user control with first name,last name,gender.Now i put this control in web page called employee.aspx. I have a button on that page "Add employee".for each click on that button i should add one user control. I tried in so many ways like taking for loop and adding user control but its not retaining state.It's loosing previous controls data. Please suggest me best approach with some sample code. Thanks in advance

      Kiran Kumar.CH (MCP)

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      You need to add the controls in page_init for viewstate to be restored. One way to do this is to use a hidden control to store the number of controls needed, and use a known naming protocol. Another is to have a finite number of possible employees and to show them rather than create them. A third is to store the data from the controls as text data such as XML, in a hidden control, and then use that to recreate/repopulate your controls.

      Christian Graus Driven to the arms of OSX by Vista.

      1 Reply Last reply
      0
      • K kiran kumar Intelligroup

        Hi folks, I am breaking my head since two days. Here is the scenario. I have a user control with first name,last name,gender.Now i put this control in web page called employee.aspx. I have a button on that page "Add employee".for each click on that button i should add one user control. I tried in so many ways like taking for loop and adding user control but its not retaining state.It's loosing previous controls data. Please suggest me best approach with some sample code. Thanks in advance

        Kiran Kumar.CH (MCP)

        B Offline
        B Offline
        Brij
        wrote on last edited by
        #3

        Is veiwstate enabled?

        Cheers!! Brij

        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