Here is some code I've been playing with to display all items that have been changed in a web and all subwebs in a visual webpart (it grabs a heap of info and chucks it in a label):
protected void Page_Load(object sender, EventArgs e)
{
String ChangeLog = "";
SPChangeQuery query = new SPChangeQuery(false,false);
query.Add = true; query.Update = true; query.Delete = true;
query.File = true; query.Item = true;
SPChangeCollection CurrentSiteChanges = SPContext.Current.Site.GetChanges(query);
foreach(SPChange Change in CurrentSiteChanges)
{
if (Change.GetType() == typeof(SPChangeItem))
{
SPChangeItem ChangeItem = Change as SPChangeItem;
using (SPWeb Web = SPContext.Current.Site.OpenWeb(ChangeItem.WebId))
{
foreach (SPWeb ChildWeb in SPContext.Current.Web.GetSubwebsForCurrentUser())
{
SPFile Item = Web.GetFile(ChangeItem.UniqueId);
if (Item.Exists)
{
/*
ChangeLog += "File: <a href='" + Item.Url + "'>" + Item.Name + "</a> @ " + ChangeItem.Time.ToString() + " | Site: " + Web.Title + "<br />";
*/
}
}
}
}
}
lbl_Webs.Text = ChangeLog;
}
I want to know how I can place the info in the commented section of the code above into a control that displays items like other webparts usually do (don't know what this control will be, a ListView or something). Can anybody advise how to do this, or suggest an alternative if I'm doing this completely wrong?