Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
190
Lost data on second postback
posted

Hi all!

I've encounterd such problems: i'll try to explain step by step

1) (server) In page_load i make databind to grid

2) (client) On the client i see the value 100 in the cell, it's right.

3) (client) I click on cell and change value to 50  and click button to make postback

4) (server) I make databind on page_load

5) (server) In button_click I see the value of cell: 50 - it's correct

6) (client) I click button  again

7)  (server) I make databind on page_load

8) (server)  In button_click I see the value of cell: 100 !!!!!

What the problem?

If before step 6 I change cell value, on step 8 I see correct value.

Please help it's ver frustrating 

 

  • 1332
    posted

    Hello,

    You are rebinding on everytime on postback which overwrites your modifed data with original data if you have not saved. Only bind WebGrid on initial page load.

  • 45
    posted

    In Step 1. you say that you're binding data to the grid; try initializing the yourGrid.DataSource in a handler for the grid's InitializeDataSource event. This will help prevent any "order of operations" issues that can pop up with the grid.

    Cheers,
    Mark.