Simple Edit screen with WebGrid

4 replies. Last post: April 12, 2010 11:07 PM by Yudi
Tags :
  • (None)
  • New Discussion
  • New Question
  • New Product Feedback
Eric Member

Hi

I have a simple screen with some edit fields and a WebGrid. The data comes from the database and gets written to the database. Reading and writing is one single stored procedure call (the WebGrid should not do anything itself).

The grid contains a RowChecker column and a RadioButton column (ColumnType=Custom).

What happens right now:

1. Page_Init

2. Page_Load: If not postback load data from database

3. grid_InitializeDataSource: From the data data read previously a DataTable gets created and passed to the WebGrid by grid.DataSource=dt, grid.DataBind()

4. User changes some checkboxes in the grid and presses Save. A Postback starts.

5. Page_Init

6. Page_Load, but no reading from database, because postback

7. grid_InitializeDataSource: The grid is emptied, because no data around.

8. SaveButton_Click: Trying to read selected user selection from the grid, but grid is empty.

So as you can see, this doesn't work. I expected that the postback keeps the data in the grid (and not call InitializeDataSource again), so that I can read it in the SaveButton_Click. How should this work? Is there a sample around for this scenario?

If I change Page_Load or grid_InitializeDataSource to read in the database again, all user selections get lost. So that is not the way to go. Any ideas?

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