views:

77

answers:

3

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.

A: 

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.

chris
but if i fill table in Load event it saves properties of controls.
Varyanica
Can you set the enableviewstate property so it doesn't save the state?
chris
+1  A: 

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).

BritishDeveloper
A: 

Dynamically adding controls is best executed in the OnInit event.

TheGeekYouNeed