Search code examples
javascriptasp.netgridviewpostbackviewstate

Gridview losing changes made via Javascript on postback


I have a Gridview that I bind some data to. I have checkboxes on each row of the Gridview that I use to delete records via Javascript. The delete works good. The problem I have is that when I do a postback on the page, all the deleted records reappear. I'm assuming this is some viewstate issue.

How can I get the Javascript deleted rows to stay deleted on a postback?


Solution

  • You have to databind the grid again on postback with the fresh datasource, that does not contain the deleted items ! If the datasource contains the old items, then they will show up again.