Your GridView just show data from a DataTable or better from List. You need to save this data. In fact your datasource. To save your objects you will need to do a deep copy (How do you do a deep copy of an object in .NET (C# specifically)?) of it. Then you just need a list to hold the different versions. If you using the memento design-pattern and generics you can build a general class for undo/redo which you can use in other programs or components too.
Maybe my example can help:
[Serializable()]
public class clsSchnappschuss<T>
{
private MemoryStream mvArbeitspeicherZugriff;
private BinaryFormatter mvFormatierer;
public clsSchnappschuss()
{
if (Attribute.GetCustomAttribute(typeof(T), typeof(SerializableAttribute)) == null)
{
Trace.WriteLine(string.Concat(typeof(T).FullName,
" ist nicht serialisiebar!"));
throw new InvalidOperationException(string.Concat(string.Format("{0} ist nicht serialisierbar.",
typeof(T).FullName),
" Die Klasse muss das Attribut ",
"Serializable einbinden ",
"[Serializable()] ",
"um clsSchnappschuss verwenden zu ",
"können."));
}
mvFormatierer = new BinaryFormatter();
}
public clsSchnappschuss<T> BxSpeichern(T obj)
{
mvArbeitspeicherZugriff = new MemoryStream();
mvFormatierer.Serialize(mvArbeitspeicherZugriff, obj);
return this;
}
public T BxWiederherstellen()
{
mvArbeitspeicherZugriff.Seek(0, SeekOrigin.Begin);
mvFormatierer.Binder = new clsCustomBinder();
T obj = (T)mvFormatierer.Deserialize(mvArbeitspeicherZugriff);
mvArbeitspeicherZugriff.Close();
return obj;
}
}
In this class the data will be stored:
public class clsAufbewahrer<T>
{
private List<clsSchnappschuss<T>> Liste;
public clsAufbewahrer()
{
Liste = new List<clsSchnappschuss<T>>(10);
}
public clsAufbewahrer(int listenKapazität)
{
Liste = new List<clsSchnappschuss<T>>(listenKapazität);
}
public List<clsSchnappschuss<T>> Schnappschuesse
{
get;
set;
}
}