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; newList.Update();
To create, update and delete list items:
SPListItem itm = myList.Items.Add(); itm["Title"] = "Test Item"; itm["Data 1"] = "Flamingo"; itm.Update(); //*** Update the item itm["Data 1"] = "Dalmation"; itm.Update(); //*** Delete the item itm.Delete();
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.
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