I am trying to write one program such that, when ever a feature is activated then it should display the activated time in the sharepoint list. for that i written following code.
public class Feature1EventReceiver : SPFeatureReceiver
{
// Uncomment the method below to handle the event raised after a feature has been activated.
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
SPSite site = properties.Feature.Parent as SPSite;
SPWeb web = site.RootWeb;
SPList list = web.Lists["Features Tracker"];
if (list == null)
{
Guid listid = web.Lists.Add("Features Tracker", "Trakcs the feature activation time", SPListTemplateType.GenericList);
web.Lists[listid].Fields.Add("Activated Time", SPFieldType.DateTime, true);
SPView myview = web.Lists[listid].DefaultView;
myview.ViewFields.Add("Activated Time");
myview.Update();
}
SPListItem listitem = list.Items.Add();
listitem["Activated Time"] = DateTime.Now.TimeOfDay;
}
}
I created another feature with same functionality. Now there is no error. But, time stamp is not inserted into the "Features Tracker" list. Any solution??