SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question

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.

share|improve this answer
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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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