Posts

Showing posts with the label Change Created By value

How to change value of Created By field or Modified By field?

You can change Created By column value or Modified By column value. To do this use below given code :             using (SPSite site = new SPSite(SPContext.Current.Web.Url))             {                 using (SPWeb web = site.OpenWeb())                 {                     SPList list = web.Lists.TryGetList("MyList");                     SPListItem item = list.GetItemById(1);                     web.AllowUnsafeUpdates = true;                     //You can use user id (integer)                      //item[SPBuiltInFieldId.Author] = SPContext.Current.Web.CurrentUser.ID; ...