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.

Advertisements
WSS Practice: Working with ListItems

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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