asp.net page life-cycle question

I have a Table and a Button. Table's cells have controls LiteralControl and CheckBox. I check some fields and then by click on button i remove these fields from database. On event Page_PreRender i clear Table and then fill it with updated data. Then it shows me Table with updated data. But if i check fields of table again and do a click on a button it wont do what i expected. In Page_Load event i see that it dont save properties of controls. Checked CheckBox controls appears as unchecked.

Answers


yeah tricky. really you want to have all the data bound before any event handling. i.e. bind your data OnInit or OnLoad (OnInit is better if you can to save viewstate).

Then handle the events i.e. delete rows or whatever you are doing and THEN get and rebind the new data in the eventhandler itself (after your deletion operation).


I assume that the button is posting back, you're doing your updates, and then you're trying to ensure that the new data is reloaded.

What you probably want to do is redirect to your page after the update - do a search for "GET AFTER POST" for more information.


Dynamically adding controls is best executed in the OnInit event.


Need Your Help

Fisheye distortion of MovieClip (AS3)

flash actionscript-3 visualization fisheye distortion

Some pseudo-code for accomplishing a linear fisheye distortion of a MovieClip's contents would be very appreciated.