Grid Resets after PostBack

2 replies. Last post: April 14, 2010 1:00 PM by Eric
Tags :
  • (None)
  • New Discussion
  • New Question
  • New Product Feedback
Eric Member

This is a follow-up to the following thread:

http://www.intersoftpt.com/Community/WebGrid/Simple-Edit-screen-with-WebGrid/

The problem there was solved. Because this is a new problem, I started a new thread. Attached is a simplified sample, written from scratch and showing the problem.

What happens:

1. Start the application and change the URL to include a parameter ?id=1 and set breakpoints

2. Event Page_Init

3a Event Page_Load

3b LoadDataFromDatabase

4. grid_InitializeDataSource

5. Page_PreRender

6. n x grid_InitializeRow

7. Now manually change on the screen some selections in the grid and press Save

8. Event Page_Init

9a Event Page_Load (PostBack is true)

9b LoadDataFromDatabase

10. grid_InitializeDataSource

11a btnSave_Click

11b ReadDataFromUserSelection

12. Page_PreRender

13. n x grid_InitializeRow

Comment 1: Step 9b (LoadDataFromDatabase) is also necessary even if PostBack is true, because we need to re-read all the read-only data. Also we need this to create our array of data in the internal structures. Otherwise we would have to store all this in the session or viewstate somehow. The data will get updated later in step 11b to hold the real values.

Comment 2: Well, in step 11 we don't write the data to the database as we should do, because for this example the DB data is hardcoded. But as you can see, no additional call to read the database is being done. In step 11b the data in the internal structure (_Models) is correct and reflects the users changes. You can see that no additional call to ReadDataFromDatabase is being made, so it should display the last selection.

Problem: After saving (after all above steps) the screen shows the initial database data instead of the changed data. At some point the user changes are reverted for some reason.

.NET Framework 2.0, ISNet Framework 3.0.5000.705, WebGrid 6.0.7200.218, testing on Windows XP IIS

 

1 attachment
All times are GMT -5. The time now is 11:42 AM.
Previous Next