For one of our Tam Tam projects we needed a history. Users can alter some topic text through the use of the r.a.d.editor control in a WebPart. After every change the new version of the text is stored into a history . These versions are shown in another WebPart containing for each version a link. By pressing such a link the user can see that version back into the first WebPart.

We decided to use an issue list in the background. The following code examples will show you how to add a new item, and changes on that item into the issue list.
To add a history item the code is as follow:
public int Add(string title, string comment)
{
SPList list = GetList();
SPListItem myItem = null;
// build CAML query
SPQuery query = new SPQuery();
query.Query = String.Format("<Where><Eq><FieldRef Title=\"Value\" /><Value Type=\"Text\">{0}</Value></Eq></Where>", title);
// get items based on CAML query
SPListItemCollection items = list.GetItems(query);
if (items.Count == 0)
{
// so create the first history item
myItem = list.Items.Add();
myItem["Title"] = title;
}
else
{
myItem = items[0];
}
// set comment
myItem["Comment"] = comment;
// update item
// if list item is changed a history row is added
myItem.Update();
return myItem.ID;
}
The code contains a call to a member GetList() which is method written by us to get access to the SPIssueList in the background. To add an first version of the text just use the following code:
int newIssueID = Add("SomeIssue", "This issue is about something");
storing changes as a new version is as follow:
Add("SomeIssue", "This comment for this issue has been changed");
In this case we presume that the Title will always be unique, but you could also use a second method based on the returned newIssueID like the following:
public bool AddHistory(int issueID, string comment)
{
SPList list = GetList();
SPListItem myItem = list.GetItemByID(issueID);
if (myItem != null)
{
// set comment
myItem["Comment"] = comment;
// update item
// if list item is changed a history row is added
myItem.Update();
return true;
}
return false;
}
Then your call in code would be like this:
AddHistory(newIssueID, "This comment for this issue has been changed");