SPSecurity.RunWithElevatedPrivileges(delegate()
{
SPWeb currentWeb = SPContext.Current.Web;
SPList lst = currentWeb.Lists["Sample"];
SPListItemCollection myColl = lst.Items;
SPListItem item = myColl.Add();
item["Title"] = txtTitle.Text;
SPFieldUserValue value = new SPFieldUserValue(currentWeb, currentWeb.CurrentUser.ID, currentWeb.CurrentUser.LoginName);
item["Author"] = value.LookupId;
item.Update();
});
No comments:
Post a Comment