Below is a code snippet to programmatically create a SharePoint List Item using the Server Object Model.
Note - Please replace the place holders with actual values before using the code.Create SharePoint List Item (using Server Object Model)
using(SPSite site = new SPSite("http://SHAREPOINT_SITE_URL"))
{
using(SPWeb web = site.RootWeb)
{
SPList list = web.Lists["LIST_NAME"];
SPListItem listItem = list.Items.Add();
listItem["Title"] = "this item is added programmatically via code";
//Update other in similar way
listItem.Update();
}
}
Client Object Model and REST is more preferred and fast way for creating SharePoint content.
Have Questions? Post them here!
More Posts related to SharePoint,
- error CAML Query containing special characters
- [Solved] SharePoint Illegal operation attempted on a registry key that has been marked for deletion
- Trigger Flow on selected Listitem from SharePoint view - create button with JSON column formatting
- SharePoint Excel error - The workbook cannot be opened because it contains the following features that are not supported by Excel in the browser
- Send Email with attachment using SharePoint PowerShell, SMTP server
- How to show or hide columns in SharePoint Online List Library from
- SharePoint excel error - A problem occurred while connecting to the server. If the problem continues, contact your administrator.
- How to get SharePoint Online user details from person or group column using REST API
- How to get SharePoint List Item URL using PowerShell
- How to get the SharePoint Tenant Login URL
- Special character & not working with SharePoint REST API
- How to disable SharePoint subsite creation option for owners
- Managed Metadata error - The data returned from the tagging UI was not formatted correctly
- Deploy SharePoint wsp solution package using PowerShell
- How to create classic site in SharePoint Online
- See actual SharePoint error exception modify web.config
- 'Edit Document' Requires a Windows Sharepoint Services-compatible application and Microsoft Internet Explorer 6.0 or higher
- How to enable anonymous public access for SharePoint Online site collection, file, folder without login ?
- SharePoint installation error - Setup is unable to proceed due to the following error This product requires Microsoft .Net Framework 4.5
- How to add animated Gif to SharePoint Online Page
- [Solved] SharePoint Search Internal server error exception
- How to create SharePoint Document Library
- SharePoint - Use Today's Date Time in list view filter and calculated column
- How to redirect SharePoint Site Collection to different URL
- SharePoint error cannot connect to the configuration database
More Posts:
- How to make TextEdit the default text Editor on Mac - MacOS
- Test Timeout using JUnit 4 with examples - Java
- What is Terminal Velocity and its Formula? How to calculate it programmatically? - Python
- Fix - 412 Cookies Are Disabled error in Exchange Admin Center when you click hybrid - Microsoft
- Pass data between two Android Activities and access it using Intent - Android
- Python Sleep Function/Method Code Example - Python
- List of All 35 Reserved Keywords in Python Programming Language 3.11 - Python
- [Fix] brew: command not found Mac or Linux Terminal Error - MacOS