.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Lee Hnetinka

Home >> Code Snippets >> SharePoint >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Modifying Created By and Modified By column in sharepoint list

Posted By:Sunil Yadav       Posted Date: May 26, 2010    Points: 10    Category: SharePoint    URL: http://www.dotnetspark.com  

I this code i am going to show how we can modify Created By and Modified By column.

Created by and Modified By are system default columns.You cannot directly edit Created by or Modified By column in sharepoint out of box. All you need to do is make the column display in your view.

Here is the code..
SPSite site = new SPSite("http://intranet");
SPWeb web = site.OpenWeb();
web.AllowUnsafeUpdates = true;
SPList list = web.Lists["User Details"];
SPListItemCollection collection = list.Items;
foreach (SPListItem item in collection)
SPUser user = web.EnsureUser(@"intranet\Administrator");
item["Created By"] = @"intranet\sunil"; // Created By field
web.AllowUnsafeUpdates = false;



Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend