WSS Practice: Working with ListItems

I’m preparing for the WSS Application Developer’s exam, and looking through the thing’s you’re supposed to know about, I decided I needed some practice. I’m starting with the very basics – creating, updating and deleting List Items…

SPListItem itm = myList.Items.Add();
itm["Title"] = "Test Item";
itm["Data 1"] = "Flamingo";
itm["Data 2"] = DateTime.Now.ToUniversalTime().ToString() ;
itm.Update();
Console.WriteLine("Item Created");
Console.ReadLine();
//*** Update the item
itm["Data 1"] = "Dalmation";
itm.Update();
Console.WriteLine("Item Updated");
Console.ReadLine();
//*** Delete the item
itm.Delete();
Console.WriteLine("Item Deleted");

Not a lot to say about that really. It’s pretty obvious. I still find it interesting the way you sort of create an ’empty’ list item, and then have to fill in its data before updating it again to ‘create’ the item, but it makes sense. The other bits – well, pretty straight forward.

WSS Practice: Working with ListItems

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.