RE: Adding Controls to a Page 2005-02-23 - By Boudreau, Duane
We'll here's what I've decided to do.
I load the controls on the page (in the Page_Init() method) and add a text box that contains the number of check boxes I am dynamically adding to the page. On the post back I loop from 1 to textbox.value and check to see if the Request["cbname" + x] is null. I can't think of anything else and this seems to fix the problem.
D
-----Original Message----- From: John Brathwaite [mailto:team@(protected)] Sent: Wednesday, February 23, 2005 3:52 PM To: aspnet-controlbuilding@(protected) Subject: [aspnet-controlbuilding] RE: Adding Controls to a Page
Duane, you're best to start with the simple controls on your page and ensure that their state is persisted, then add your code and other controls incrementally until you find out what's causing the state to be lost. Are you able to take this approach?
Cheers John
-----Original Message----- From: Boudreau, Duane [mailto:BoudreauD@(protected)] Sent: Thursday, 24 February 2005 2:08 a.m. To: aspnet-controlbuilding@(protected) Subject: [aspnet-controlbuilding] RE: Adding Controls to a Page
I added code to enable view state enabled - no difference. Would it help if I posted the entire aspx and cs files?
Duane
-----Original Message----- From: John Brathwaite [mailto:team@(protected)] Sent: Tuesday, February 22, 2005 6:01 PM To: aspnet-controlbuilding@(protected) Subject: [aspnet-controlbuilding] RE: Adding Controls to a Page
Duane, do you have EnableViewState=true for your asp:textbox and other controls?
Cheers John
-----Original Message----- From: Boudreau, Duane [mailto:BoudreauD@(protected)] Sent: Wednesday, 23 February 2005 11:11 a.m. To: aspnet-controlbuilding@(protected) Subject: [aspnet-controlbuilding] RE: Adding Controls to a Page
That's the thing - I'm not setting any values.
I am using checkboxes, which are not maintaining state and text boxes which are not saving data that is entered.
Duane
-----Original Message----- From: Thomas Johansen [mailto:aylar@(protected)] Sent: Tuesday, February 22, 2005 4:53 PM To: aspnet-controlbuilding@(protected) Subject: [aspnet-controlbuilding] RE: Adding Controls to a Page
Only set the e.g. the Text property on the initial load, NOT on the postback;
if (!IsPostBack) { someControl.Text = "Some Text"; }
- Thomas
-----Original Message----- From: Boudreau, Duane [mailto:BoudreauD@(protected)] Sent: Tuesday, February 22, 2005 10:25 PM To: aspnet-controlbuilding@(protected) Subject: [aspnet-controlbuilding] RE: Adding Controls to a Page
I added the code to create the controls dynamically to the Page_Load() method post back, and in the OnInit() method, but in both cases the data is not being preserved.
What am I doing wrong?
Duane
-----Original Message----- From: Joe Bradvica [mailto:JoeB@(protected)] Sent: Tuesday, February 22, 2005 3:10 PM To: aspnet-controlbuilding@(protected) Subject: [aspnet-controlbuilding] RE: Adding Controls to a Page
You have to re-add the controls on postback. The data is then repopulated to the controls and you can access the data.
Joe B.
Need SQL Advice? http://sqladvice.com Need RegEx Advice? http://regexadvice.com Need XML Advice? http://xmladvice.com
Need SQL Advice? http://sqladvice.com Need RegEx Advice? http://regexadvice.com Need XML Advice? http://xmladvice.com
Need SQL Advice? http://sqladvice.com Need RegEx Advice? http://regexadvice.com Need XML Advice? http://xmladvice.com
Need SQL Advice? http://sqladvice.com Need RegEx Advice? http://regexadvice.com Need XML Advice? http://xmladvice.com
Need SQL Advice? http://sqladvice.com Need RegEx Advice? http://regexadvice.com Need XML Advice? http://xmladvice.com
Need SQL Advice? http://sqladvice.com Need RegEx Advice? http://regexadvice.com Need XML Advice? http://xmladvice.com
Need SQL Advice? http://sqladvice.com Need RegEx Advice? http://regexadvice.com Need XML Advice? http://xmladvice.com
|
|