SPSecurity.RunWithElevatedPrivileges(delegate
{
using (SPSite site = new SPSite(SPContext.Current.Site.ID))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists[ListName];
SPListItem newitem = list.Items.Add();
newitem["Title"] = "New lookup";
SPFieldLookupValue newValue = new SPFieldLookupValue(1, "Title1");
newitem["Title1"] = newValue;
newitem.Update();
}
}
});
{
using (SPSite site = new SPSite(SPContext.Current.Site.ID))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists[ListName];
SPListItem newitem = list.Items.Add();
newitem["Title"] = "New lookup";
SPFieldLookupValue newValue = new SPFieldLookupValue(1, "Title1");
newitem["Title1"] = newValue;
newitem.Update();
}
}
});
No comments:
Post a Comment