I have a page that has two grids. I need to collect all the data from both grids as well as additional info from various other controls on the page and validate, then save it. If the data doesn't validate against our validation logic, I need to allow the user to make necessary changes then attempt to save again.
This page is solely for new data, so technically there is no datasource to connect to. Here's what I've done. The grids are set up for Ajax and are batch edit. I've got a button on my page that calls JS to save changes to both grids if either of them has changes. Otherwise, it triggers a save changes of the rest of the page data. I've set my grids to bind to public properties on my page that are pulling from a Session Object. This way when I save the rest of the page data in the Page_PreRender event, I can combine it with the rest (the two grids feed child collections off a main object, being populate from the various other controls on the page).
But I've got a snag. How do I reset the grid records, so that if I can't save due to validation, when the user clicks the save button again, the grid is still triggering an Insert instead of an Update?
Reading through other threads made me think it had something to do with ajax, but because I don't have a true datasource, ajax is what is keeping the data in the grid when the user clicks the save button. And I need this to happen in case of a validation failure.
I hope all this makes sense. Can anyone help? Maybe there is a better way to collect all this new data. I'm just not sure.