Tuesday, April 10, 2007

Day of Dot Net 2007 Speaker

I'll be speaking at Day of Dot Net 2007 in Ann Arbor 5/5 - see you there!! I'll be talking about SharePoint 2007 - WSS & MOSS & all that good stuff!



Day of .Net May 5, 2007 - I'll be there!

Wednesday, April 04, 2007

SPListItem.Update isn't updating!

Here's a good one. Why doesn't this work:

SPList myList = myWeb.Lists["MyList"];

for (int i == 0; i < myList.Count; i++)
{
myList.Items[i]["Value"] = "42";
myList.Items[i].Update();
}

This *should* set the Value column to 42 for every item in the list. But for some reason, no exception, no Event Log entry, running with impersonation, etc etc - this just doesn't work.

The reason: laziness. Here's what does work:

SPList myList = myWeb.Lists["MyList"];

for (int i == 0; i < myList.Count; i++)
{
SPListItem myItem = myList.Items[i];
myItem["Value"] = "42";
myItem.Update();
}

myItem isn't disposable, so that should do the trick.