The following example will demonstrate , how we will add the Items to the List Programatically
SPSecurity.RunwithElevatedPrivilages(delegate()
{
using(SPSite oSite=new SPSite(SPContext.Current.Site.Url))
{
using (SPWeb oWeb = oSite.OpenWeb())
{
SPList oList = oWeb.Lists.TryGetList("MyListName");
if (oList != null)
{
SPListItem oListItem = oList.GetItems().Add();
oListItem["Column1"] = "Column 1 Value";
oListItem[""Column1"] = "Column 2 Value";
oListItem.Update();
}
}
}
});
SPSecurity.RunwithElevatedPrivilages(delegate()
{
using(SPSite oSite=new SPSite(SPContext.Current.Site.Url))
{
using (SPWeb oWeb = oSite.OpenWeb())
{
SPList oList = oWeb.Lists.TryGetList("MyListName");
if (oList != null)
{
SPListItem oListItem = oList.GetItems().Add();
oListItem["Column1"] = "Column 1 Value";
oListItem[""Column1"] = "Column 2 Value";
oListItem.Update();
}
}
}
});
Related Post
List
- Column formatting in modern list view
- List view render using JSLink with Fabric UI
- PowerShell :: Delete All List Items
- Get List Field Type using ECMA Script in SP Hosted Apps
- What is the Content Type for Custom List in SharePoint 2013, SharePoint 2010
- Related Items Column in SharePoint 2013
- Bulk Insert/Update/Delete Items from SharePoint List/Library
- Create list in SharePoint 2013 using OOB feature:
- Difference between List Definition , List Template and List Instance
- Create List Definition in SharePoint 2013
- Set List/Library Default Content Type Programatically
- Adding Content Type to List/Library Programatically
- Difference between List and Library in SharePoint
SharePoint
- Build Automation (CICD) of WebJob in SharePoint Online
- List view render using JSLink with Fabric UI
- Delete Quick Links using Powershell
- SharePoint Interview Questions and Answers..
- Issues:SharePoint Foundation 2013 Prerequisites installation(off line) on Windows Server2012 R2
- SharePoint Column Field Types
- Alternate to InfoPath Forms in SharePoint
- Get the Items inside the Folder in document Library in SharePoint 2013 using REST API
- SharePoint 2016 [Beta] Release Date
- SharePoint Modal Dailoge to Open Page
- What is Look up Column and how to use in SharePoint 2010,2013
- People Picker Check User Entry and Resolve
- How to Get User Data from AD (Active Directory) in SharePoint Using C#
- History of SHAREpoINt
- How to Create Application Page in SharePoint using Visual Studio 2010,2013
- Retrieve Site Features in SharePoint
- Weather Webpart by using Yahoo Service in Share Point
- Activate Telnet Client in Windows Server
- Navigate to another Page After Clicking on JavaScript Alert
- How to read List Item Version Collection Programmatically
- How to get Worker Process from Command Prompt
- How to Use DataTable.js in SharePoint webpart
- Adding New Link to PromotedActions Delegate Control in SharePoint 2013
- How to Deploy Master Page in Share Point
- Get Role Definition in SharePoint
0 comments:
Post a Comment