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