I am new to SharePoint 2010, can you please help me to create a SharePoint list and basic CRUD operations?


To create a list:

 Guid newListId = site.Lists.Add("My Custom List", "This list was created programmatically", site.ListTemplates["Custom List"]);
 //This is optional = just to get the list and put it on the left navigation.
 SPList newList = site.Lists[newListId];
 newList.OnQuickLaunch = true;

To create, update and delete list items:

 SPListItem itm = myList.Items.Add();
 itm["Title"] = "Test Item";
 itm["Data 1"] = "Flamingo";
 //*** Update the item
 itm["Data 1"] = "Dalmation";
 //*** Delete the item

To get an item: SPListItem itm = myList.GetItemById( itemId );

You can also use SPQuery to get a list item or many items.

A long time ago I wrote about how to perform some of these basic tasks in some blog posts.

  • This answer definitely points out the basics. However, its worth pointing out that if a user does not has permissions to create list, create list item, edit list item, or delete list items, etc., SP will throw ugly errors. I learned this the hard way. Almost every object in SP has a .doesUserHasPermissions() method. You should definitely play around with that. It will help you write more robust code. – harsimranb Jul 24 '12 at 22:40

Very much depend on how you want to create that list.

  • As enduser through UI
  • As developer programmatically
  • As IT-Pro using powershell

If it's as an end-user the

  • Click Site Actions
  • click View All Site Content
  • click Create

For more options see Create or delete a list

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.