Click here to Skip to main content
15,915,829 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
anyone tell me how to undo last change made into datatable in window c#



sir i have a datatable in which i perform some operation (like sum,subtract etc) i want a functionality that revert only last change that i have made in gridview( for eg if i delete "@" sign from gridview data i want it revert back )by clicking on undo button pls hlep me
Posted
Updated 30-Jun-14 1:23am
v2
Comments
Prasad Avunoori 30-Jun-14 7:15am    
What do you mean? Please explain.

1 solution

You can can use RejectChanges. It will revert all changes since the last call to AcceptChanges.
I guess the trick is to know when to call AcceptChanges.
It should be done before the next row is added.
If you have a a function for adding a new row to the data table you can do likes this.

C#
private DataTable dt = new DataTable();
private void AddRow()
{
  dt.AcceptChanges();
  dt.Rows.Add(param1, param2, etc);
}

private void OnUndo()
{
   dt.RejectChanges();
}


This is a very simplistic approach.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900