Хутка і лёгка: Атрымаць SPFolder з SPListItem ў прыёмнік падзей

Я ненавіджу прызнавацца ў гэтым, but I struggled with this one all day. My event receiver needs to update a field of its parent folder. This little bit shows how to do it:

прыватны ануляваць UpdateParentFolder(SPItemEventProperties ўласцівасці)
{

SPFolder thisItemFolder = properties.ListItem.File.ParentFolder;
thisItemFolder.Item["ZZ Approval Status"] = "Good news, ўсё!";
thisItemFolder.Item.Update();


} // UpdateParentFolder

У гэтым выпадку, I’m working with a document library and the properties are coming from an ItemAdded event.

The trick is that you can’t get the SPFolder of the item directly from the item itself (I.E. properties.ListItem.Folder is null). Замест, go to the list item’s associated File and get the File’s folder.

</канец>

Падпісацца на мой блог!

Technorati Тэгі:

Адна думка пра «Хутка і лёгка: Атрымаць SPFolder з SPListItem ў прыёмнік падзей

Пакінуць каментар

Ваш электронны адрас не будзе апублікаваны. Абавязковыя палі пазначаныя * *