views:

292

answers:

2

Hi


Let’s assume that ( the first time page is created ) I manually bind GridView to some data source. Is there’s a way to configure GridView to delete a row ( by pressing row’s delete button) without handling any of the delete events ( in other words, we wouldn’t try to delete a row in data source and then rebind GridView to it)? Instead, GridView would simply remove that row from its ViewState and then display all rows minus the deleted one


thanx

+1  A: 

So then how would you end up remembering this and deleting it in the db? Why not do what may be simplier is to have a bit field in your table called Deleted. That way when someone deletes something accidentally it is still there.

Your record set would make use of a WHERE clause to filter Deleted=False

JonH
I'm thinking of situations where we would want our app to bind to DB only once, and from there on application would use and manipulate that data locally and also display the results of data manipulation in GridView on each postback. Thus, the results of this manipulation would only have meaning for that particular application and thus saving the results back into DB wouldn't be an option
SourceC
Look into ASP.net ajax and throw your datagrid in an updatepanel. The effects are very impressive.
JonH
+1  A: 

Instead of binding the GridView to your data source, bind it to a collection built from your data source. You can then add to, delete from and modify the collection as much as you want, without ever affecting the underlying database table.

Jason Berkan
that's true, but I thought GridView had an option to automatically delete the row, without attaching any event handlers or without using ObjectDateSource.UpdateMethod
SourceC