User control loses data on post back
-
I'm having an issue with post backs that I can't seem to figure out. I have a user control and a web form. The user control contains a and it is populated with data. So on the web form code behind it calls the user control method "PopulateUsers" which adds TableRows to the . Also on the web form it has a save button. Now when the save button is clicked, it posts back and then my asp:Table is blank (because I have it not populating on a post back). How can I maintain the current data during a postback that is in a user control? I have tried enabling view state on the controls, and all the pages with no luck.
-
I'm having an issue with post backs that I can't seem to figure out. I have a user control and a web form. The user control contains a and it is populated with data. So on the web form code behind it calls the user control method "PopulateUsers" which adds TableRows to the . Also on the web form it has a save button. Now when the save button is clicked, it posts back and then my asp:Table is blank (because I have it not populating on a post back). How can I maintain the current data during a postback that is in a user control? I have tried enabling view state on the controls, and all the pages with no luck.
If you are creating a table dynamically then you will need to handle the viewstate yourself. Here is a link that will show you a number of articles on the subject: http://lmgtfy.com/?q=dynamic+controls+viewstate+asp.net[^]
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me