{"id":727,"date":"2018-10-22T12:02:36","date_gmt":"2018-10-22T12:02:36","guid":{"rendered":"http:\/\/blog.softreeconsulting.com\/?p=727"},"modified":"2018-10-22T12:02:36","modified_gmt":"2018-10-22T12:02:36","slug":"crud-operations-list","status":"publish","type":"post","link":"https:\/\/softreetechnology.com\/blog\/sharepoint\/crud-operations-list\/","title":{"rendered":"Crud Operations on a List"},"content":{"rendered":"<p>This code block is related to create, delete, update and add list items to a custom list.<\/p>\n<p>[code lang=&#8221;c&#8221;]<\/p>\n<p>using System;<br \/>\nusing Microsoft.SharePoint.Client;<br \/>\nusing System.Security;<\/p>\n<p>namespace List_Crud_Operations<br \/>\n{<br \/>\nclass Program<br \/>\n{<br \/>\nstatic void Main(string[] args)<br \/>\n{<br \/>\nClientContext ctx = new ClientContext(&#8220;http:\/\/portal\/sites\/site1&#8221;);<br \/>\nWeb web = ctx.Web;<br \/>\nvar password = &#8220;Password&#8221;;<br \/>\nSecureString secureString = new SecureString();<br \/>\nforeach (char c in password.ToCharArray()) secureString.AppendChar(c);<\/p>\n<p>ctx.Credentials = new SharePointOnlineCredentials(&#8220;user@domain.com&#8221;, secureString);<br \/>\nListCreationInformation creationInfo = new ListCreationInformation();<br \/>\ncreationInfo.Title = &#8220;My Custom List&#8221;;<br \/>\ncreationInfo.Description = &#8220;List Creation On SPO&#8221;;<br \/>\ncreationInfo.TemplateType = (int)ListTemplateType.GenericList;<br \/>\nList mylist = web.Lists.Add(creationInfo);<br \/>\nctx.Load(mylist);<br \/>\nctx.ExecuteQuery(); \/\/create a list<\/p>\n<p>mylist = web.Lists.GetByTitle(&#8220;Existing Custom List&#8221;);<br \/>\nmylist.DeleteObject();<br \/>\nctx.ExecuteQuery(); \/\/ delete an existing list<br \/>\nmylist = web.Lists.GetByTitle(&#8220;My Custom List&#8221;);<br \/>\nmylist.Description = &#8220;update the list&#8221;; \/\/Update list<br \/>\nmylist.Update();<\/p>\n<p>for (int i = 0; i &lt; 10; i++)<br \/>\n{<br \/>\nListItemCreationInformation itemInfo = new ListItemCreationInformation();<br \/>\nListItem item = mylist.AddItem(itemInfo);<br \/>\nitem[&#8220;Title&#8221;] = &#8220;Item&#8221; + i ;<br \/>\nitem.Update();<br \/>\n}<\/p>\n<p>ctx.ExecuteQuery(); \/\/ add items to custom list<br \/>\n}<br \/>\n}<br \/>\n}<\/p>\n<p>[\/code]<\/p>\n<p><strong>This solution is brought to you by our SharePoint professionals.<\/strong><\/p>\n<p style=\"text-align: justify;\"><a href=\"http:\/\/www.softreeconsulting.com\/\"><strong>Softree Consulting<\/strong><\/a>\u00a0employs SharePoint consultants; we are a technology services provider with the aim to help companies achieve exceptional performance through SharePoint. Our dedicated team of SharePoint consultants has the right bent of mind to understand and execute customer requirements.<\/p>\n<p style=\"text-align: justify;\">Be it SPFx or SharePoint add-in developments,\u00a0<strong>SharePoint 2019 developments<\/strong>, web part developments, migrating from SharePoint 2010\/2013 to SharePoint 2013\/2016\/Office 365, Office 365, <a href=\"http:\/\/www.softreeconsulting.com\/sharepoint-azure-ad\/\">SharePoint hosted apps development<\/a> or something else in SharePoint, we strive to deliver the best<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This code block is related to create, delete, update and add list items to a custom list. [code lang=&#8221;c&#8221;] using System; using Microsoft.SharePoint.Client; using System.Security; namespace List_Crud_Operations { class Program { static void Main(string[] args) { ClientContext ctx = new ClientContext(&#8220;http:\/\/portal\/sites\/site1&#8221;); Web web = ctx.Web; var password = &#8220;Password&#8221;; SecureString secureString = new SecureString(); foreach (char c in password.ToCharArray()) secureString.AppendChar(c); [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43],"tags":[56,159,172],"class_list":["post-727","post","type-post","status-publish","format-standard","hentry","category-sharepoint","tag-sharepoint","tag-sharepoint-online","tag-sharepointadd-in"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Crud Operations on a List - Softree Technology<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/softreetechnology.com\/blog\/sharepoint\/crud-operations-list\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Crud Operations on a List - Softree Technology\" \/>\n<meta property=\"og:description\" content=\"This code block is related to create, delete, update and add list items to a custom list. [code lang=&#8221;c&#8221;] using System; using Microsoft.SharePoint.Client; using System.Security; namespace List_Crud_Operations { class Program { static void Main(string[] args) { ClientContext ctx = new ClientContext(&#8220;http:\/\/portal\/sites\/site1&#8221;); Web web = ctx.Web; var password = &#8220;Password&#8221;; SecureString secureString = new SecureString(); foreach (char c in password.ToCharArray()) secureString.AppendChar(c); [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/softreetechnology.com\/blog\/sharepoint\/crud-operations-list\/\" \/>\n<meta property=\"og:site_name\" content=\"Softree Technology\" \/>\n<meta property=\"article:published_time\" content=\"2018-10-22T12:02:36+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Crud Operations on a List - Softree Technology","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/softreetechnology.com\/blog\/sharepoint\/crud-operations-list\/","og_locale":"en_US","og_type":"article","og_title":"Crud Operations on a List - Softree Technology","og_description":"This code block is related to create, delete, update and add list items to a custom list. [code lang=&#8221;c&#8221;] using System; using Microsoft.SharePoint.Client; using System.Security; namespace List_Crud_Operations { class Program { static void Main(string[] args) { ClientContext ctx = new ClientContext(&#8220;http:\/\/portal\/sites\/site1&#8221;); Web web = ctx.Web; var password = &#8220;Password&#8221;; SecureString secureString = new SecureString(); foreach (char c in password.ToCharArray()) secureString.AppendChar(c); [&hellip;]","og_url":"https:\/\/softreetechnology.com\/blog\/sharepoint\/crud-operations-list\/","og_site_name":"Softree Technology","article_published_time":"2018-10-22T12:02:36+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/crud-operations-list\/#article","isPartOf":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/crud-operations-list\/"},"author":{"name":"admin","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/person\/98740297642f06debccdcee2de84086b"},"headline":"Crud Operations on a List","datePublished":"2018-10-22T12:02:36+00:00","mainEntityOfPage":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/crud-operations-list\/"},"wordCount":259,"commentCount":0,"publisher":{"@id":"https:\/\/softreetechnology.com\/blog\/#organization"},"keywords":["SharePoint","SharePoint Online","SHAREPOINTADD-IN"],"articleSection":["SharePoint"],"inLanguage":"en","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/softreetechnology.com\/blog\/sharepoint\/crud-operations-list\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/crud-operations-list\/","url":"https:\/\/softreetechnology.com\/blog\/sharepoint\/crud-operations-list\/","name":"Crud Operations on a List - Softree Technology","isPartOf":{"@id":"https:\/\/softreetechnology.com\/blog\/#website"},"datePublished":"2018-10-22T12:02:36+00:00","breadcrumb":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/crud-operations-list\/#breadcrumb"},"inLanguage":"en","potentialAction":[{"@type":"ReadAction","target":["https:\/\/softreetechnology.com\/blog\/sharepoint\/crud-operations-list\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/crud-operations-list\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/softreetechnology.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Crud Operations on a List"}]},{"@type":"WebSite","@id":"https:\/\/softreetechnology.com\/blog\/#website","url":"https:\/\/softreetechnology.com\/blog\/","name":"Softree Technology","description":"Celebrating 10+ Years in SharePoint Consulting !","publisher":{"@id":"https:\/\/softreetechnology.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/softreetechnology.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en"},{"@type":"Organization","@id":"https:\/\/softreetechnology.com\/blog\/#organization","name":"Softree Technology","url":"https:\/\/softreetechnology.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2023\/03\/cropped-white-logo-soft.png","contentUrl":"https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2023\/03\/cropped-white-logo-soft.png","width":844,"height":230,"caption":"Softree Technology"},"image":{"@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/person\/98740297642f06debccdcee2de84086b","name":"admin","image":{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6fc78c8a7aa3fb0bf43c3b9a2e3962d7?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6fc78c8a7aa3fb0bf43c3b9a2e3962d7?s=96&d=mm&r=g","caption":"admin"},"sameAs":["https:\/\/softreeconsulting.com"],"url":"https:\/\/softreetechnology.com\/blog\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/posts\/727","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/comments?post=727"}],"version-history":[{"count":0,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/posts\/727\/revisions"}],"wp:attachment":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/media?parent=727"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/categories?post=727"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/tags?post=727"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}